ASP.NET Core MVC Interview Question #102

What is authorization in ASP.NET Core MVC?

Authentication, Authorization, Security & State Management Mid-Level Intermediate

Quick Interview Answer

Authorization determines whether an authenticated or anonymous user is allowed to access a resource or perform an operation. ASP.NET Core supports authorization through attributes, roles, claims, policies, requirements, and handlers.

Detailed Explanation

Authorization determines whether an authenticated or anonymous user is allowed to access a resource or perform an operation. ASP.NET Core supports authorization through attributes, roles, claims, policies, requirements, and handlers.

Authorization must be enforced on the server. Hiding a button in a Razor view improves the user interface but does not protect the corresponding controller action.

Code Example

[Authorize]
public class AccountController : Controller
{
    public IActionResult Profile() => View();
}