Asp.net Membership Provider Gets UserName from UserId

I often asked a question about a known username and how to get a UserId accordingly. How about a different way?

For some reason, I have a UserId, but I don't want to include the aspnet_User table in my data entities. Is there a way to get the username without querying the aspnet_User table?

+4
source share
1 answer
MembershipUser user = Membership.GetUser(); if (user != null) string name = user.UserName; 

Internally, this will result in access to the ASP.NET user table. There is no way to avoid this.

+2
source

Source: https://habr.com/ru/post/1335788/


All Articles