robaherne
asked on
Problem redirecting from login page
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(t xt_Name.Te xt, txt_Password.Text))
{
// Log the user into the site
FormsAuthentication.GetAut hCookie(tx t_Name.Tex t, chk_RememberMe.Checked);
}
// user's credentials were invalid
lbl_InvalidMessage.Visible = true;
}
protected void OnLoggedIn(object sender, EventArgs e)
{
System.Threading.Thread.Sl eep(3000);
if (User.IsInRole("Band"))
{
Response.Redirect("~/PageB and.aspx") ;
}
else if (User.IsInRole("Venue"))
{
Response.Redirect("~/PageV enue.aspx" );
}
}
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(t
{
// Log the user into the site
FormsAuthentication.GetAut
}
// user's credentials were invalid
lbl_InvalidMessage.Visible
}
protected void OnLoggedIn(object sender, EventArgs e)
{
System.Threading.Thread.Sl
if (User.IsInRole("Band"))
{
Response.Redirect("~/PageB
}
else if (User.IsInRole("Venue"))
{
Response.Redirect("~/PageV
}
}
ASKER
Sorry I don't know what you mean by setting a break point... where would I do that?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Congrats. You would expect in the OnLoggedIn event the user would have been logged in already. Oh well.
You can probably do this by getting the user using the UserName using Membership.FindUsersByName