Я попытался создать простой проект CRUD Blazor hello world, чтобы вызвать Web API для изучения Blazor. Однако, когда я попытался запустить httpclient.PostJsonAsyn c или httpclient.PutJsonAsyn c (). Система выбрасывает ниже исключения. Я использовал почтальон для проверки API, и все операции Get / Post / Put / Delete работали. Я попытался использовать метод PostAsyn c и вручную создать объект содержимого для параметра, но результат тот же. Я пытался использовать asp. net core 3.0 и 3.1, но также не смог.
Исходный код веб-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)```