ASP.NET -- Redirect user based on role

Posted on 2011-05-12
Last Modified: 2012-05-11
In the code below, I am trying to get the users role, and redirect them to the appropriate page.  The problem is that the first time I try to login, both ticketmasters and admin roles are false, but the second time I try logging in, the correct role is detected.  This is driving me nuts.  Can anyone point out where I am going wrong?

    Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoggedIn
        ' Login Ticketmasters or Admins
        Dim strRole As String = Roles.GetRolesForUser(Login1.UserName).ToString

        If Roles.IsUserInRole("Admins") Then
        End If
Question by:rrhandle8

    Accepted Solution

    Answered my own question. I was not including the username

    Debug.Print(Roles.IsUserInRole(Login1.UserName, "Admins").ToString)

    Author Closing Comment

    Answered it myself before anyone else made any comments.
    LVL 12

    Expert Comment

    i think you need to change the following code:

     If Roles.IsUserInRole("Admins") Then
    else Roles.IsUserInRole(strRole) Then
     //redirection to other page based on role......
     End If

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    6 Experts available now in Live!

    Get 1:1 Help Now