gpt4 book ai didi

asp.net - Blazor WebAssembly : The provided ContentType is not supported;

转载 作者:行者123 更新时间:2023-12-03 14:51:53 34 4
gpt4 key购买 nike

我今天通过以下命令行安装了 Blazor WebAssembly 示例项目 (WeatherForecast):

dotnet new blazorwasm --hosted -o ProjectName
我在 Debug模式下通过 Visual Studio 2019 安装后直接启动了 SPA。浏览器是:Chrome。浏览器显示应用程序,但是当我选择导航菜单“获取数据”时,什么也没有发生。 Chrome 显示 1 个错误:
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: The provided ContentType is not supported; the supported types are 'application/json' and the structured syntax suffix 'application/+json'.
System.NotSupportedException: The provided ContentType is not supported; the supported types are 'application/json' and the structured syntax suffix 'application/+json'.
at System.Net.Http.Json.HttpContentJsonExtensions.ValidateContent (System.Net.Http.HttpContent content) <0x2e87f38 + 0x0009a> in <filename unknown>:0
at System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync[T] (System.Net.Http.HttpContent content, System.Text.Json.JsonSerializerOptions options, System.Threading.CancellationToken cancellationToken) <0x2e87d30 + 0x00006> in <filename unknown>:0
at System.Net.Http.Json.HttpClientJsonExtensions.GetFromJsonAsyncCore[T] (System.Threading.Tasks.Task`1[TResult] taskResponse, System.Text.Json.JsonSerializerOptions options, System.Threading.CancellationToken cancellationToken) <0x2e40838 + 0x0011c> in <filename unknown>:0
at BlazorIssue.Client.Pages.FetchData.OnInitializedAsync () [0x00033] in D:\Projects\BlazorIssue\Client\Pages\FetchData.razor:43
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync () <0x2b8cb98 + 0x0013a> in <filename unknown>:0
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask (System.Threading.Tasks.Task taskToHandle) <0x2dd8340 + 0x000b6> in <filename unknown>:0
Chrome 显示以下请求 header :
Blazor WebAssembly Request Headers
上下文信息:
  • Chrome :V83.0.4103.61(64位)
  • Blazor:V3.2.0
  • Visual Studio:V16.6.0
  • 点网 V3.1.300
  • DotNet SDK:V3.1.300

  • 这很奇怪,因为这个示例项目的全新安装昨天没有问题。

    最佳答案

    如果客户端项目被指定为启动项目,这可能发生在 Web 程序集模板项目的 ASP.NET 托管版本中。确保将服务器项目设置为启动项目。

    Blazor WebAssembly - Server - Startup Project

    关于asp.net - Blazor WebAssembly : The provided ContentType is not supported;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62082133/

    34 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com