2
所以,我有代碼控制器:FormsAuthentication.SetAuthCookie不起作用
FormsAuthentication.SetAuthCookie("hello", true); throw new Exception("" + User.Identity.IsAuthenticated);
,它始終顯示錯誤。原因可能是什麼?
所以,我有代碼控制器:FormsAuthentication.SetAuthCookie不起作用
FormsAuthentication.SetAuthCookie("hello", true); throw new Exception("" + User.Identity.IsAuthenticated);
,它始終顯示錯誤。原因可能是什麼?
只有當用戶開始發回cookie時,纔會在下一個請求中對用戶進行身份驗證。表單身份驗證僅在請求開始時發生。如果您真的需要,您可以將HttpContext.Current.User更改爲自定義身份驗證身份,但是您應該重做一次。