相关疑难解决方法(0)

Thread.CurrentPrincipal.Identity vs HttpContext.User.Identity

可能重复:
http.context.user和thread.currentprincipal之间的区别以及何时使用它们?

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

我知道在HttpContext.User.Identity用户通过身份验证时设置了FormsAuthentication.但什么时候Thread.CurrentPrincipal.Identity设置?

他们总是保持相同的价值吗?

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

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

14
推荐指数
1
解决办法
1万
查看次数

10
推荐指数
1
解决办法
4023
查看次数

AuthenticationManager.SignIn上的HttpContext.Current.User.Identity

我正在使用ASP.Net Identity来管理我的用户.

在调用以下内容后我发现:

AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = isPersistent }, identity);
Run Code Online (Sandbox Code Playgroud)

当我检查用户当前是否通过HttpContext.Current.User.Identity.IsAuthenticated它进行身份验证返回false.

我设法true通过执行以下操作来获取此信息:

FormsAuthentication.SetAuthCookie(model.UserName, false);
Run Code Online (Sandbox Code Playgroud)

是否可以设置HttpContext.Current.User.Identity.IsAuthenticatedtrue

asp.net-mvc asp.net-identity

1
推荐指数
1
解决办法
2675
查看次数