I would like to redirect user to particular page depending on the role assigned to them. Since there will be more than 1 user with the same role the code I'm using is not what I need. I'm using the ASP.NET Configuration to assign roles and set up 3 different roles. Admin, Customer, Partners. Each role will have many users. After user logins depending on their role I would like the to be redirected to a particular page. Via:Admin, Customer or Partner. My question is: can anyone help me either change the code I'm using or let me know if the code I'm using will not work. I need to not look for a SPECIFIC user name to look for ANY user name that is in a role. Any help would be appreciated.
My Code:
protected void LoginButton_Click(object sender, EventArgs e)
{
if (Roles.IsUserInRole(LoginControl.UserName, "admin1"))
{ Response.Redirect("~/AdminPages/Administration.aspx");
}
else if (Roles.IsUserInRole(LoginControl.UserName, "customer1"))
{
Response.Redirect("~/Customers/Customers.aspx");
}
else if (Roles.IsUserInRole(LoginControl.UserName, "partner1"))
{
Response.Redirect("~/Partners/Partners.aspx");
}
}