ASP.NET -- Redirect user based on role

Posted on 2011-05-12
Medium Priority
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
  • 2

Accepted Solution

rrhandle8 earned 0 total points
ID: 35751628
Answered my own question. I was not including the username

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

Author Closing Comment

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

Expert Comment

ID: 35751635
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Integration Management Part 2
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

850 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