asp.net mvc get current logged in user id [duplicate]
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);
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
精彩评论