Posted 1 April 2019, 8:11 pm EST
Hello everyone I am trying to check what Role my user is in with the default setup.
I thought I would only need ‘User.IsInRole(“User”)’ for in my View but its not so easy.
I want to display certain links depending on the role for the user.
Here is what I have and I tried a few different options.
I have the default setup database and some added tables that dont matter for this part.
Request.IsAuthenticated works for login.
01
@if (Request.IsAuthenticated)
02
{
03
04
Assign Roles
05
06
07
View Roles
08
09
} else if (Request.IsAuthenticated && User.IsInRole(“User”))
10
{
11
12
user Else clause
13
14
} else if (Request.IsAuthenticated && User.IsInRole(“Guest”))
15
{
16
17
Guest Else clause
18
19
} else
20
{
21
22
else else!! Else clause
23
24
}