Mid ASP.NET Core

Securing routes with [Authorize] and [AllowAnonymous]?

  • [Authorize]: Requires authenticated user
  • [Authorize(Roles = "Admin")]: Requires role
  • [AllowAnonymous]: Allows access without login

Example:

[Authorize]

public IActionResult Dashboard() { }

[AllowAnonymous]

public IActionResult Login() { }

More from ASP.NET Core Tutorial

All questions for this course