下面是我用來登錄的代碼。它返回並說明成功。但是,如果我嘗試獲取UserID,或者在任何頁面上執行User.Identity.IsAuthenticated,它就會顯示爲false。Asp.Identity OWIN Cookie未驗證
我想不通這裏會發生什麼。
var SignInManager = Context.GetOwinContext().GetUserManager<ApplicationSignInManager>();
var result = SignInManager.PasswordSignIn(txtUsername.Text, txtPassword.Text, false, true);
switch (result)
{
case SignInStatus.Success:
Response.Redirect(User.IsInRole("Admin") ? "~/Admin/Dashboard.aspx" : "~/User/Dashboard.aspx");
break;
case SignInStatus.LockedOut:
Response.Redirect("~/Account/Lockout");
break;
case SignInStatus.RequiresVerification:
Response.Redirect("~/Account/Unknown",true);
break;
case SignInStatus.Failure:
default:
txtErrorMessage.Text = "Invalid Username/Password";
txtPassword.Text = "";
break;
}
這幾乎就像它說的成功,但它真的不能正常工作。 我已經嘗試了很多不同的東西,但似乎沒有任何東西讓我認證。
「瀏覽器關閉後仍然存在」,我不認爲這是OP的問題。 – mxmissile
它的確如此,在我的項目中,我用等於寫在這個問題上,但只是改變了這個參數 –