我使用ASP.Net身份來管理我的用戶。HttpContext.Current.User.Identity上AuthenticationManager.SignIn
我發現,調用以下後:
AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = isPersistent }, identity);
當我檢查,如果用戶通過HttpContext.Current.User.Identity.IsAuthenticated
目前驗證它返回false
。
我設法讓這個做回true
如下:
FormsAuthentication.SetAuthCookie(model.UserName, false);
是否有可能設置HttpContext.Current.User.Identity.IsAuthenticated
到true
?
在什麼時候,你檢查'HttpContext.Current.User.Identity.IsAuthenticated'?如果在簽名後立即發生,這可能是錯誤的。加載另一頁後它仍然是錯誤的嗎?另外,發佈你的'web.config',以及如何配置ASP.NET Identity的詳細信息。 –
嗨,我已經解決了像這樣:HttpContext.GetOwinContext()。Authentication.User.Identity' ..現在的問題是:是正確的方式? –