How to get current user in Asp.Net MVC

[From]: http://stackoverflow.com/questions/263486/how-to-get-current-user-in-asp-net-mvc

If you need to get the user from within the controller, use the User property of Controller. If you need it from the view, I would populate what you specifically need in the ViewData, or you could just call User as I think it’s a property of ViewPage.

shareedit

You can get the name of the user in ASP.NET MVC4 like this:

HttpContext.Current.User.Identity.Name
shareedit
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s