[英]asp.net membership provider get UserName by UserId
I have seen a lot of question asking about known user name and how to retrieve UserId accordingly. 我已经看到很多问题,询问已知的用户名以及如何相应地检索UserId。 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. 由于某种原因,我有UserId,但是我不想将aspnet_User表包含到我的数据实体中。 Is there any way I can retrieve the user name without querying against aspnet_User table?
有什么方法可以检索用户名而无需查询aspnet_User表?
MembershipUser user = Membership.GetUser();
if (user != null)
string name = user.UserName;
Internally, this will access the ASP.NET user table. 在内部,这将访问ASP.NET用户表。 There's no way to avoid that.
无法避免这种情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.