app.UseStaticFiles();
app.UseExceptionHandler("/Home/Error");
app.UseStatusCodePagesWithReExecute("/Home/Error/{0}");
app.UseAuthentication();
app.UseAuthorization();
app.UseSession();
app.UseCookiePolicy(new CookiePolicyOptions
{
MinimumSameSitePolicy = SameSiteMode.Strict,
HttpOnly = HttpOnlyPolicy.Always
});
app.UseMvcWithDefaultRoute();
app.UseCustomMiddleware();
public void Configure(IApplicationBuilder app)
{
app.UseMiddleware1();
app.UseMiddleware2();
// ...
}
app.Run(async context =>
{
await context.Response.WriteAsync("Hello, world!");
});
dotnet add package Microsoft.AspNetCore.Authentication
app.UseMiddleware<DiagnosticsMiddleware>();