Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When login button pressed, after validating user credential
C#
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, "abc", DateTime.Now, DateTime.Now.AddMinutes(30), false, "1", FormsAuthentication.FormsCookiePath);
        string hash = FormsAuthentication.Encrypt(ticket);
        HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);
        if (ticket.IsPersistent)
        {
            cookie.Expires = ticket.Expiration;
        }

        Response.Cookies.Add(cookie);


Now if do not write code Response.Redirect("Login.aspx") [as I want after successful login user should be in the same page that is Login.aspx ] after cookie add then my "LoginView" control does not recognize as Logged-In User.

If I click again on log-in button or any other control or refresh the page than "LoginView" control along with other control "LoginStatus" and "LoginName" work fine and recognize as Logged-In User. So, Is there an way just after login button press "LoginView" work fine.

Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900