Membership.GetUser() 与 Context.User
Membership.GetUser() 和 Context.User 之间有什么区别,建议在获取有关当前用户的信息时使用哪一个?
What are the differences between Membership.GetUser() and Context.User, and which is recommended for use in getting information about the current user?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您没有为您的站点配置成员资格,则 getuser() 将不会产生任何结果。
Context.user 是传递给 asp.net 运行时的身份令牌,如果为站点配置了除匿名访问之外的任何身份验证,则将生成用户。
If you don't have membership configured for your site, getuser() won't yield anything.
Context.user is the identity token handed to the asp.net runtime, and will yield a user if any authentication aside from anonymous acces is configured fo the site.
Membership.GetUser 意味着使用 MembershipProvider。它只是从配置的任何存储中检索用户信息。 (例如ActiveDirectory、SQL Server)。 Context.User 是当前请求的 IPrincipal 安全上下文。
Membership.GetUser implies the use of a MembershipProvider. It simply retrieves user information from whatever store is configured. (e.g. ActiveDirectory, SQL Server). Context.User is the IPrincipal security context for the current Request.