Solved

How to find user role with IdentityHelper, then redirect

Posted on 2015-02-02
2
472 Views
Last Modified: 2015-02-23
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

0
Comment
Question by:rrhandle8
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Expert Comment

by:Naitik Gamit
ID: 40585596
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 40585906
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

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET Textbox input validation 4 77
Can Angular be used with classic asp.net? 3 41
ASP.NET Built-In Report Creator / Viewer 5 41
Multi-Column Repeater 3 39
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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