Blazor Client Side Online Store: Part 7 - Updated to release version 3.2.0 and added image display



Hello, Habr! Blazor WebAssemby released and I updated my site a bit. For details, welcome to cat.

Content



References


→  Sources
Images on the Docker Registry

Updates


Install a new template with the release version of Blazor

dotnet new -i Microsoft.AspNetCore.Components.WebAssembly.Templates::3.2.0

Added a link to the package for convenient work with HttpClient

 <PackageReference Include="Microsoft.Extensions.Http" Version="3.1.3" />
 <PackageReference Include="System.Net.Http.Json" Version="3.2.0" />

Added a new way to initialize HttpClient so that it automatically grabs authorization tokens in its headers

services.AddHttpClient("BlazorEShop", client => 
        client.BaseAddress = new Uri(cfg.ApiUri))
    .AddHttpMessageHandler(sp =>
        sp.GetRequiredService<AuthorizationMessageHandler>()
            .ConfigureHandler(new[] { cfg.ApiUri },scopes: new[] { "api" }));
services.AddTransient(sp => 
    sp.GetRequiredService<IHttpClientFactory>().CreateClient("BlazorEShop"));

Well, the level of logs has lowered. In general, now it is possible to set it through environment variables or through appsettings.json which lies in wwwroot.

 builder.Logging.SetMinimumLevel(LogLevel.Debug);


What's New in Blazor WebAssembly


It is possible to get configs from json files and from environment variables.
It is possible to localize through .resx resource files.
It is possible to automatically add the jwt token to the headers upon request.
More details can be seen in this video .

Upload pictures


So far, only through the swagger.

Log in by clicking the Authorize button in the upper right corner and popping up a checkmark in the lower left corner.



We upload the file and copy the identifier that was returned to us. We



use the identifier that was copied in the previous step as imageId


All Articles