Thread.CurrentPrincipal.Identity VS HttpContext.User.Identity [英] Thread.CurrentPrincipal.Identity vs HttpContext.User.Identity
问题描述
可能重复:
<一href="http://stackoverflow.com/questions/3057937/difference-between-http-context-user-and-thread-currentprincipal-and-when-to-use">difference http.context.user和Thread.CurrentPrincipal中之间何时使用它们?
是什么在ASP.NET应用程序中这两者之间的区别是什么?
What's the difference between these two in an ASP.NET application?
我知道 HttpContext.User.Identity
当用户通过 FormsAuthentication
验证设置。但是,当是 Thread.CurrentPrincipal.Identity
集?
I know the HttpContext.User.Identity
is set when the user is authenticated through FormsAuthentication
. But when is the Thread.CurrentPrincipal.Identity
set?
难道他们始终保持相同的值?
Do they always hold the same value?
这是否仍然适用于那些没有访问应用程序的其他层的的HttpContext
?
Does that still hold true for other layers of the application that do not have access to a HttpContext
?
推荐答案
HttpContext.User.Identity是当前登录的用户在你的Web应用程序。
HttpContext.User.Identity is the current logged in user in your web app.
Thread.CurrentPrincipal中
只适用于当&LT;身份验证模式=窗口/&GT;
。通常,这是与基于Windows的应用程序中使用(的WinForms,WPF ..)
Thread.CurrentPrincipal
applies only when the <authentication mode = "windows"/>
. Normally this is using with Windows based applications (Winforms,WPF..)
这篇关于Thread.CurrentPrincipal.Identity VS HttpContext.User.Identity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!