WebSecurity.IsAuthenticated无效

时间:2013-11-12 05:41:14

标签: asp.net

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

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应该在这里 - &gt; &LT;! -

WebSecurity.IsAuthenticated应该在这里 - &gt;错误&lt; - !

WebSecurity.CurrentUserId应该在这里 - &gt; -1&lt; - !

Context.User.Identity.IsAuthenticated应该在这里 - &gt;错误&lt; - !

WebSecurity.IsConfirmed(userName)应该在这里 - &gt; &LT; - ! 注销

0 个答案:

没有答案