11

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);
Community
  • 1
  • 1
niao
  • 4,972
  • 19
  • 66
  • 114

1 Answers1

3

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

Mahesh Velaga
  • 21,633
  • 5
  • 37
  • 59