How to find user role with IdentityHelper, then redirect

How do I find the role the user belongs to then redirect to a page in the Admin folder if they belong to the Admin role.


    Protected Sub LogIn(sender As Object, e As EventArgs)
        If IsValid Then
            ' Validate the user password
            Dim manager = New UserManager()
            Dim user As ApplicationUser = manager.Find(UserName.Text, Password.Text)
            If user IsNot Nothing Then
                IdentityHelper.SignIn(manager, user, RememberMe.Checked)
                IdentityHelper.RedirectToReturnUrl(Request.QueryString("ReturnUrl"), Response)
            End If
        Else
            FailureText.Text = "Invalid username or password."
            ErrorMessage.Visible = True
        End If
        End If
    End Sub

Open in new window

rrhandle8Asked:
Who is Participating?
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
You should be able to use something along the lines of:
Dim inRole As Boolean = UserManager.IsInRole(user.Id, "Admin")

Open in new window

0
 
Naitik GamitSoftware DeveloperCommented:
0
All Courses

From novice to tech pro — start learning today.