I have installed the Blazor WebAssembly Example Project (WeatherForecast) today by the following command line:
dotnet new blazorwasm --hosted -o ProjectName
I started the SPA directly after the installation via Visual Studio 2019 in Debug Mode. The Browser is: Chrome. The Browser shows the app, but when I select the Nav Menu "Fetch Data" then nothing happens. Chrome shows 1 Error:
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 shows the following Request Headers:
Context-Information:
That is curious because a fresh installation of this example project worked yesterday with no problems.
To create a new Blazor WebAssembly project with an authentication mechanism: After choosing the Blazor WebAssembly App template in the Create a new ASP.NET Core Web Application dialog, select Change under Authentication. Select Individual User Accounts to use ASP.NET Core's Identity system.
Blazor projects are slow on the client-side because you have to download the entire dot net runtime along with the necessary DLL libraries on your browser. Additionally, Blazor apps have latency issues.
Inject NavigationManager in razor. Use Uri from NavigationManager to get the current URL.
This can happen in the ASP.NET Hosted version of the Web Assembly template project if the Client project is designated as the Startup project. Ensure that the Server project is set as the Startup project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With