How to set middleware on new minimum syntax for blazor apps

Joaquim Antonio Petronilho Nunes 21 Reputation points
2021-12-09T18:30:24.407+00:00

When I create a new Blazor App Visual Studio uses a template with minimum syntax, just like below:

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

builder.Services.AddSyncfusionBlazor();

var app = builder.Build();

await app.RunAsync();

In this new scenario, how do I set middleware, such as:

app.UseStaticFiles();

Developer technologies .NET Blazor
{count} votes

Accepted answer
  1. AgaveJoe 30,126 Reputation points
    2021-12-09T18:37:24.84+00:00

    The default Blazor WASM template loads the static file handler by default.

    ASP.NET Core Middleware

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.