Mid ASP.NET Core

How to integrate authentication/authorization middleware?

app.UseAuthentication(); // Validates user identity

app.UseAuthorization(); // Applies policies/roles

Order matters: must be after routing but before endpoints.

app.UseRouting();

app.UseAuthentication();

app.UseAuthorization();

app.UseEndpoints(...);

More from ASP.NET Core Tutorial

All questions for this course