Minifycode 2020-08-24 Viewed 1.5K times ASP.Net Core MVC

In this article, you will learn how to claimsPrincipal in ASP.Net core MVC web app

In this article, ClaimsPrincipal.Current isn't set in ASP.NET Core. So, it uses dependency injection to provide dependencies such as the current user's identity.

There are several options for retrieving the current authenticated user's ClaimsPrincipal:

  • ControllerBase.User (MVC controller).
  • Passed in from caller (libraries without access to HttpContext).
  • IHttpContextAccessor (when passing around the user's identity too much).
  • HttpContext.User (middleware).

ClaimsPrincipal in ASP.Net core MVC web app
minify code