无法从asp.net核心Blazor服务器项目向Web API发布创建操作

时间:2020-01-20 04:02:23

标签: asp.net-core asp.net-web-api blazor-server-side

我试图构建一个简单的CRUD Blazor hello world项目,以调用Web API来学习Blazor。但是,当我尝试运行httpclient.PostJsonAsync或httpclient.PutJsonAsync()时。系统抛出以下异常。 我使用邮递员来测试api,并且所有的Get / Post / Put / Delete操作都可以正常工作。 我尝试使用PostAsync方法并为参数手动编写内容对象,但结果相同。我尝试使用asp.net core 3.0和3.1,但也失败了。

Web API https://github.com/felixckt/wiseally/tree/master/Azure%20SQL%20Web%20API

的源代码

该项目的源代码https://github.com/felixckt/wiseally/tree/master/BlazorApp2

'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.0\System.Diagnostics.StackTrace.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.0\System.Reflection.Metadata.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.0\System.Collections.Immutable.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer: Warning: Unhandled exception rendering component: Response status code does not indicate success: 500 (Internal Server Error).

System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at Microsoft.AspNetCore.Components.HttpClientJsonExtensions.SendJsonAsync[T](HttpClient httpClient, HttpMethod method, String requestUri, Object content)
   at BlazorApp2.Pages.SalesOrder.Create.CreateSalesOrder() in C:\Users\ktcheung\source\Repos\wiseally\BlazorApp2\BlazorApp2\Pages\SalesOrder\Create.razor:line 39
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.Forms.EditForm.HandleSubmitAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost: Error: Unhandled exception in circuit 'vLwAz2qhwpmqSd5Cp3wzBI7yykxoK9aob15MooceeEQ'.

System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at Microsoft.AspNetCore.Components.HttpClientJsonExtensions.SendJsonAsync[T](HttpClient httpClient, HttpMethod method, String requestUri, Object content)
   at BlazorApp2.Pages.SalesOrder.Create.CreateSalesOrder() in C:\Users\ktcheung\source\Repos\wiseally\BlazorApp2\BlazorApp2\Pages\SalesOrder\Create.razor:line 39
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.Forms.EditForm.HandleSubmitAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)```

0 个答案:

没有答案
相关问题