これは、この問題に関する私の 2 番目の投稿です。この問題について何日も読んでいます。
LoginOk = WebSecurity.Login(email, password, rememberMe) **Is true but**
WebSecurity.IsAuthenticated, WebSecurity.CurrentUserName and the other items do not get set on the LoggedIn Page.
// Attempt to log in using provided credentials
if (WebSecurity.Login(email, password, rememberMe)) {
// Added this code for testing...
LoginOk = WebSecurity.Login(email, password, rememberMe);
if (LoginOk)
{
Response.Redirect("~/Account/LoggedIn");
return;
}
Context.RedirectLocal(returnUrl);
return;
} else {
ModelState.AddFormError("The user name or password provided is incorrect.");
}
/Account/LoggedIn ページのコード
<p>Lake LoggedIn page </p>
<p>WebSecurity.CurrentUserName should be here -> <strong>@WebSecurity.CurrentUserName</strong> <-! </p>
<p> WebSecurity.IsAuthenticated should be here -> <strong> @WebSecurity.IsAuthenticated </strong><-!</p>
<p> WebSecurity.CurrentUserId should be here -> <strong> @WebSecurity.CurrentUserId </strong><-!</p>
<p> Context.User.Identity.IsAuthenticated should be here -> <strong> @Context.User.Identity.IsAuthenticated </strong><-!</p>
@if (!userName.IsEmpty()) {
<p> WebSecurity.IsConfirmed(userName) should be here -> <strong> @WebSecurity.IsConfirmed(userName) </strong><-!</p>
}else{
<p> WebSecurity.IsConfirmed(userName) should be here -> <-!</p>
}
<a href="~/Account/Logout" title="Logout">Logout</a>
</div>
これは上記のLoggedInコードの結果です
WebSecurity.CurrentUserName はここにあるはずです -> <-!
WebSecurity.IsAuthenticated はここにあるべきです -> False <-!
WebSecurity.CurrentUserId はここにあるべきです -> -1 <-!
Context.User.Identity.IsAuthenticated はここにある必要があります -> False <-!
WebSecurity.IsConfirmed(userName) はここにあるはずです -> <-! ログアウト