Home >Backend Development >C++ >How Do I Access the Current User in ASP.NET MVC Controllers and Views?
In classic ASP.NET Web Forms, accessing the currently logged-in user was straightforward using Page.User
. However, ASP.NET MVC requires a different approach.
To retrieve the current user within an ASP.NET MVC controller, use the User
property of the Controller
base class. For views, you can pass the user information via ViewData
or directly access the User
property, which is available within ViewPage
.
The above is the detailed content of How Do I Access the Current User in ASP.NET MVC Controllers and Views?. For more information, please follow other related articles on the PHP Chinese website!