1

这是我关于这个问题的第二篇文章>我已经阅读了几天关于这个问题......任何建议为什么

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) 应该在这里 -> <-! 登出

4

0 回答 0