public void Configure(IApplicationBuilder app) { app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public void Configure(IApplicationBuilder app) { app.Use(async (context, next) => { context.Response.Headers.Add("X-Content-Type-Options", "nosniff"); await next(); }); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }In this example, we are adding a custom middleware that adds the X-Content-Type-Options header to the HTTP response. We are using the Use() method to add our middleware before routing and endpoint mapping. Package library: Microsoft.AspNetCore.Builder.