Thread.CurrentPrincipal.Identity vs HttpContext.Us

2019-02-21 08:33发布

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?

2条回答
Fickle 薄情
2楼-- · 2019-02-21 09:08

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..)

查看更多
够拽才男人
3楼-- · 2019-02-21 09:12

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

查看更多
登录 后发表回答