You must Sign In to post a response.
  • Category: ASP.NET

    About login to database to check for authentication

    I have two module Admin and user through login page how can i go to the proper module?
  • #767625
    Hi,

    If you want to redirect to specific page based on Login user then you can check the case in Load event of that page and then redirect as you want.

    Ex:

    Protected void Page_Load(object sender, EventArgs e)
    {
    if(loginUser.ToUpper().Trim()=="ADMIN")
    {
    // redirect to your desired page
    }
    else
    {
    // redirect to normal page
    }
    }


    Hope this helps you....

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #767680
    You can store the role in the "User.Identity". You can get the role from the identity then base on the role you can redirect to your module. Following is the sample code to store the role in the "FormsAuthenticationTicket "

    FormsAuthenticationTicket ticket1 =
    new FormsAuthenticationTicket(
    1, // version
    this.TextBox_username.Text.Trim(), // get username from the form
    DateTime.Now, // issue time is now
    DateTime.Now.AddMinutes(10), // expires in 10 minutes
    false, // cookie is not persistent
    "HR" // role assignment is stored
    // in userData
    );

    By Nathan
    Direction is important than speed


Sign In to post your comments