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 MVC 4 项目。如何获取当前用户的用户 ID?我想在我的视图中显示它。
您可以使用以下代码:
MembershipUser user = Membership.GetUser(User.Identity.Name);
谢谢,史蒂夫