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.
您好,谁能帮我如何获取用户的用户 ID?如果我写 User.Identity.Name 我得到用户的名字,如果我写 User.IsInRole 我得到用户的角色。我必须写什么才能获得用户ID?
谢谢你
尝试这个 -
MembershipUser user = Membership.GetUser(User.Identity.Name); Guid userId = (Guid)user.ProviderUserKey;