troubleshooting Question

Problem redirecting from login page

Avatar of robaherne
robaherne asked on
.NET ProgrammingASP.NET
5 Comments1 Solution722 ViewsLast Modified:
I have a Login control with an LoggedIn event that redirects the user based on their role.

The problem is the first time I log in it tries to redirect me to Default.aspx, which doesn't exist. But if I go back in the browser and log in again it redirects me to the appropriate page. Whats going on?!

Thanks.

CODE:

protected void Button1_Click(object sender, EventArgs e)
    {
        // Validate the user against the Membership framework user store      
        if (Membership.ValidateUser(txt_Name.Text, txt_Password.Text))      
        {          
            // Log the user into the site          
            FormsAuthentication.GetAuthCookie(txt_Name.Text, chk_RememberMe.Checked);
           
        }      
        //  user's credentials were invalid      
        lbl_InvalidMessage.Visible = true;
    }


    protected void OnLoggedIn(object sender, EventArgs e)
    {
        System.Threading.Thread.Sleep(3000);
        if (User.IsInRole("Band"))
        {
            Response.Redirect("~/PageBand.aspx");

        }
        else if (User.IsInRole("Venue"))
        {
            Response.Redirect("~/PageVenue.aspx");
        }
    }
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros