0

我正在审查一个当前遇到身份验证问题的应用程序(表单身份验证结合使用自定义方式来检索当前用户的配置文件),我注意到用户的身份是使用不同的方法检索的:

  • Thread.CurrentPrincipal.Identity(在一些 http 模块上)
  • HttpContext.Current.User.Identity(在一些 http 模块和页面上)
  • Page.User.Identity(在页面上)

假设所有方法总是返回相同的值是否安全?

4

2 回答 2

2

HttpContext.Current.User.Identity(在一些 http 模块和页面上) Page.User.Identity(在页面上)

他们都返回一个实例IPrincipal

Page.User使用HttpContext对象的 User 属性来确定请求的来源

最好的方法是HttpContext.Current.User

Thread.CurrentPrincipal.Identity如果您使用 Impersonation 将不会显示正确的用户,而是会为您提供 windows 用户详细信息

于 2011-10-04T15:43:44.437 回答
0

我们通常使用的是HttpContext.Current.User.Identity

于 2011-10-04T15:38:59.370 回答