c# - Thread.CurrentPrincipal.Identity 与 HttpContext.User.Identity

标签 c# asp.net .net form-authentication current-principal

<分区>

Possible Duplicate:
difference between http.context.user and thread.currentprincipal and when to use them?

这两者在 ASP.NET 应用程序中有什么区别?

我知道 HttpContext.User.Identity 是在用户通过 FormsAuthentication 进行身份验证时设置的。但是 Thread.CurrentPrincipal.Identity 何时设置?

它们是否始终保持相同的值?

对于无法访问 HttpContext 的应用程序的其他层,这是否仍然适用?

最佳答案

HttpContext.User.Identity 是您网络应用程序中的当前登录用户。

Thread.CurrentPrincipal仅适用于 <authentication mode = "windows"/> .通常这是与基于 Windows 的应用程序(Winforms、WPF..)一起使用

关于c# - Thread.CurrentPrincipal.Identity 与 HttpContext.User.Identity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6810808/

相关文章:

c# - .HasRequired 无法在模型中工作

c# - 在 ExecuteFunction SP 调用中使用 unicode 参数

.net - 使用impersonate = true时如何在IIS中获取当前的应用程序池用户?

c# - 扩展 ContentView 时获取 "The name ' SomeName' does not exist in the current context"

c# - 从具有多个零值的枚举中获取项目名称

c# - 如何将网站和桌面应用程序连接到同一个数据库

c# - 由于 OnTextChanged 事件,ASP 控件需要双击才能获得焦点

c# - System.String 没有实现接口(interface) System.IConvertible

c# - 将枚举列表存储在Azure表存储中

c# - 通过路径设置JSON属性