开发者

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

开发者 https://www.devze.com 2022-12-25 01:26 出处:网络
This question already has answers here: Closed 10 years ago. Possible Duplicate: How 开发者_开发知识库do you get the UserID of a User object in ASP.Net MVC?
This question already has answers here: Closed 10 years ago.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号