在ASP.NET Core 3.0 Blazor客户端应用程序中使用OData

问题描述 投票:1回答:1
  1. 创建的ASP.NET Core 3.0 Blazor客户端应用程序
  2. 创建了.NET Standard 2.0类库,并使用OData V4客户端代码生成器扩展生成了OData代理类
  3. 已添加类库作为Blazor应用程序的项目参考
  4. 我尝试使用OData客户端从服务器消耗一些数据,但出现以下错误:
async void IncrementCount()
{
    MyContext context = new MyContext(new Uri(@"http://localhost:8080/Svc"));
    context.IgnoreResourceNotFoundException = true;
    var res = await context.Companies.ExecuteAsync();
    var count = res.ToList().Count();
    currentCount = count;
}
blazor.webassembly.js:1 WASM: Unhandled Exception:
blazor.webassembly.js:1 WASM: System.PlatformNotSupportedException: Operation is not supported on this platform.
blazor.webassembly.js:1 WASM:   at System.Net.WebProxy.CreateDefaultProxy () <0x2b023a8 + 0x00008> in <d7c7498765294217ab91d4da6fa04cb6>:0 
blazor.webassembly.js:1 WASM:   at System.Net.Configuration.DefaultProxySectionInternal.GetSystemWebProxy () <0x2b02378 + 0x00000> in <d7c7498765294217ab91d4da6fa04cb6>:0 
blazor.webassembly.js:1 WASM:   at System.Net.Configuration.DefaultProxySectionInternal.GetDefaultProxy_UsingOldMonoCode () <0x2b022d8 + 0x00000> in <d7c7498765294217ab91d4da6fa04cb6>:0 
blazor.webassembly.js:1 WASM:   at System.Net.Configuration.DefaultProxySectionInternal.GetSection () <0x2b020f0 + 0x00026> in <d7c7498765294217ab91d4da6fa04cb6>:0 
blazor.webassembly.js:1 WASM:   at System.Net.WebRequest.get_InternalDefaultWebProxy () <0x2b01c50 + 0x00030> in <d7c7498765294217ab91d4da6fa04cb6>:0 
blazor.webassembly.js:1 WASM:   at System.Net.HttpWebRequest..ctor (System.Uri uri) <0x2b00040 + 0x000d2> in <d7c7498765294217ab91d4da6fa04cb6>:0 
blazor.webassembly.js:1 WASM:   at System.Net.HttpRequestCreator.Create (System.Uri uri) <0x2aff768 + 0x00004> in <d7c7498765294217ab91d4da6fa04cb6>:0 
blazor.webassembly.js:1 WASM:   at System.Net.WebRequest.Create (System.Uri requestUri, System.Boolean useUriBase) <0x2af9058 + 0x00108> in <d7c7498765294217ab91d4da6fa04cb6>:0 
blazor.webassembly.js:1 WASM:   at System.Net.WebRequest.Create (System.Uri requestUri) <0x2af8cc0 + 0x00022> in <d7c7498765294217ab91d4da6fa04cb6>:0 
blazor.webassembly.js:1 WASM:   at Microsoft.OData.Client.HttpWebRequestMessage.CreateRequest (System.String method, System.Uri requestUrl, Microsoft.OData.Client.DataServiceClientRequestMessageArgs args) <0x2af15c8 + 0x00006> in <5d326e79a5274688a50559cf2d28aa99>:0 
blazor.webassembly.js:1 WASM:   at Microsoft.OData.Client.HttpWebRequestMessage..ctor (Microsoft.OData.Client.DataServiceClientRequestMessageArgs args) <0x2af0fa8 + 0x000a2> in <5d326e79a5274688a50559cf2d28aa99>:0 
blazor.webassembly.js:1 WASM:   at Microsoft.OData.Client.RequestInfo.CreateRequestMessage (Microsoft.OData.Client.BuildingRequestEventArgs requestMessageArgs) <0x2aec760 + 0x00260> in <5d326e79a5274688a50559cf2d28aa99>:0 
blazor.webassembly.js:1 WASM:   at Microsoft.OData.Client.ODataRequestMessageWrapper.CreateRequestMessageWrapper (Microsoft.OData.Client.BuildingRequestEventArgs requestMessageArgs, Microsoft.OData.Client.RequestInfo requestInfo) <0x2aec3e0 + 0x0000e> in <5d326e79a5274688a50559cf2d28aa99>:0 

这是限制吗?

注意:相同的代码在.NET Framework Console应用程序中正常工作

c# asp.net-core odata .net-standard blazor
1个回答
0
投票

使用ODada连接服务使CSB(客户端Blazor)的生活更加轻松。但是,如前所述,生成的代理可与服务器端blazor一起使用,对于CSB,它会给出错误。微软的家伙需要为此努力,以实现出色的开发。

© www.soinside.com 2019 - 2024. All rights reserved.