Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net mvc get current logged in user id [duplicate]

Tags:

asp.net-mvc

Possible Duplicate:
How do you get the UserID of a User object in ASP.Net MVC?

Greetings, I have created a custom membership provider to make it possible to authenticate users on my application. How can i retrieve current user id in controller? I need this to get some data from database for this user like this:

PersistanceManger.RepositoryUser.GetInformation(userROWGUID);
like image 289
niao Avatar asked Mar 27 '10 20:03

niao


1 Answers

Do you particularly need the Id of the user or the userName ?, it seems you are looking for the Guid of the present user, for this I think the retrieval of this Id depends on your implementation. If you want to retrieve information based of userName, then you can do the following:

HttpContext.Current.User gives you the User object, you can get the other information from it, for your case, you need to use HttpContext.Current.User.Identity.Name

like image 152
Mahesh Velaga Avatar answered Nov 12 '22 19:11

Mahesh Velaga