开发者

asp.net membership provider get UserName by UserId

开发者 https://www.devze.com 2023-02-04 08:50 出处:网络
I have seen a lot of question asking about known user name and how to retrieve U开发者_如何学JAVAserId accordingly. How about the other way around?

I have seen a lot of question asking about known user name and how to retrieve U开发者_如何学JAVAserId accordingly. How about the other way around?

For some reason I have UserId, but I don't want to include aspnet_User table into my data entities. Is there any way I can retrieve the user name without querying against aspnet_User table?


MembershipUser user = Membership.GetUser();
if (user != null)
    string name = user.UserName;

Internally, this will access the ASP.NET user table. There's no way to avoid that.

0

精彩评论

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