Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Can to login successfully but still showing the "Register" and "Login"

$
0
0

Hi,

I have created a new web application project for web form. Upon creation, there are a list of web form in the "Account" folder. So I went on to Register and after registration, my record is inserted into the database. Next, I went on to Login. I could login successfully, but at the right top corner (site.master), it suppose to show "Logout", but it didn't. It is still showing "Login".

I troubleshoot further in Login.aspx.cs file. 

 protected void LogIn(object sender, EventArgs e)
        {
            if (IsValid)
            {
                // Validate the user password
                var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
                var signinManager = Context.GetOwinContext().GetUserManager<ApplicationSignInManager>();

                // This doen't count login failures towards account lockout
                // To enable password failures to trigger lockout, change to shouldLockout: true
                var result = signinManager.PasswordSignIn(Email.Text, Password.Text, RememberMe.Checked, shouldLockout: false);

                switch (result)
                {
                    case SignInStatus.Success:
                        IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
                        break;
                    case SignInStatus.LockedOut:
                        Response.Redirect("/Account/Lockout");
                        break;
                    case SignInStatus.RequiresVerification:
                        Response.Redirect(String.Format("/Account/TwoFactorAuthenticationSignIn?ReturnUrl={0}&RememberMe={1}",
                                                        Request.QueryString["ReturnUrl"],
                                                        RememberMe.Checked),
                                          true);
                        break;
                    case SignInStatus.Failure:
                    default:
                        FailureText.Text = "Invalid login attempt";
                        ErrorMessage.Visible = true;
                        break;
                }
            }
        }

Using breakpoint and F11 , the result variable is "Success" and executed this line:

IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);

But, how come in my sitemaster layout , it is still showing the "Register" and "Login"?

This is my site.master

<asp:LoginView runat="server" ViewStateMode="Disabled"><AnonymousTemplate><ul class="nav navbar-nav navbar-right"><li><a runat="server" href="~/Account/Register">Register</a></li><li><a runat="server" href="~/Account/Login">Log in</a></li></ul></AnonymousTemplate><LoggedInTemplate><ul class="nav navbar-nav navbar-right"><li><a runat="server" href="~/Account/Manage" title="Manage your account">Hello, <%: Context.User.Identity.GetUserName()  %> !</a></li><li><asp:LoginStatus runat="server" LogoutAction="Redirect" LogoutText="Log off" LogoutPageUrl="~/" OnLoggingOut="Unnamed_LoggingOut" /></li></ul></LoggedInTemplate></asp:LoginView>


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>