Thread.CurrentPrincipal.Identity vs HttpContext.User.Identity [duplicate]

拟墨画扇 提交于 2019-12-04 03:01:44

问题


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

What's the difference between these two in an ASP.NET application?

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?

Does that still hold true for other layers of the application that do not have access to a HttpContext?


回答1:


HttpContext.User.Identity is the current logged in user in your web app.

Thread.CurrentPrincipal applies only when the <authentication mode = "windows"/>. Normally this is using with Windows based applications (Winforms,WPF..)




回答2:


if you use the HttpContext.User.Identity equals the Thread.CurrentPrincipal



来源:https://stackoverflow.com/questions/6810808/thread-currentprincipal-identity-vs-httpcontext-user-identity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!