Explore Library
Code Quiz

Middleware Ordering Bug

Spot the pipeline configuration mistake that breaks authorization in an ASP.NET Core app.

Codecsharp
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAuthentication();
builder.Services.AddAuthorization();
builder.Services.AddControllers();

var app = builder.Build();

app.UseRouting();
app.UseAuthorization();
app.UseAuthentication();

app.MapControllers();

app.Run();

This app fails to authenticate users before authorization runs. What is the bug?