Click here to Skip to main content
15,918,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public partial class Account_Login : System.Web.UI.Page
{
   
    protected void Page_Load(object sender, EventArgs e)
    {
        RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);
    }
    protected void LoginUser_LoggedIn(object sender, EventArgs e)
    { 
        Guid userFKey;
    MembershipUser mu = Membership.GetUser(LoginUser.UserName.ToString());
        userFKey = (Guid)mu.ProviderUserKey;

        Session["currentUId"] = userFKey.ToString();

       
        Session["user"] = LoginUser.UserName.ToLower();
        Session.Timeout = 9999;

        if (User.IsInRole("HR"))
        {
            Response.Redirect("~/HR/Hr.aspx");
        }
        else if (User.IsInRole("Admin"))
        {
            Response.Redirect("~/Admin/Admin.aspx");
        }

        else if (User.IsInRole("PR"))
        {
            Response.Redirect("~/PR/Pr.aspx");
        }
        else
        {
        }

    }
}
Posted
Comments
Orcun Iyigun 1-May-13 14:59pm    
And? Don't you think a little bit explanation can help us identify the problem? or you are expecting us to be a psychic and guess what it is?
[no name] 1-May-13 15:03pm    
when i login as admin it goes to the home page .. it should go to admin page
JasonMacD 1-May-13 15:15pm    
Is the same user that is an admin, also in any of the other roles? If so, that could be causing issues.
CPallini 1-May-13 15:17pm    
You didn't show us the code where 'User' gets its value.
arthamsai 2-May-13 7:26am    
I think You are not specifying any role condition,so it is not taking you to desired page

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