Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道有什么方法可以从 ASP.NET 中的 LoginName 控件获取当前用户的 UserName 或 UserId 吗?
您可以使用Page类的User属性:
string userName = Page.User.Identity.Name;
您可以从 Page.User.Identity.Name 或 HttpContext.Current.User.Identity.Name 中读取。