ASP.NET Core MVC Interview Question #101
What is authentication in an ASP.NET Core MVC application?
Authentication, Authorization, Security & State Management Mid-Level Intermediate
Quick Interview Answer
Authentication determines who the current user is. ASP.NET Core authentication handlers examine credentials such as an authentication cookie or bearer token and, when valid, establish a ClaimsPrincipal on HttpContext.User.
Detailed Explanation
Authentication determines who the current user is. ASP.NET Core authentication handlers examine credentials such as an authentication cookie or bearer token and, when valid, establish a ClaimsPrincipal on HttpContext.User.
Authentication alone does not decide whether a user may perform a particular operation. That decision belongs to authorization.
Code Example
if (User.Identity?.IsAuthenticated == true)
{
var name = User.Identity.Name;
}