How to get user type in view?

Asked

Viewed 77 times

1

I have an Asp.Net MVC project that uses Individual User Account with Owin. Everything is working perfectly, but I would like to get user type (role) in View.
I’m using Request.IsAuthenticated to know if the user is authenticated, then there is some way to get the roles user’s?

1 answer

2


Man, I believe something like this will solve your problem.

@if (Request.IsAuthenticated)
{
        @if (User.IsInRole("Admin"))
        {
            <li>
                @Html.ActionLink("Administrativo", "index", "Administrativo")
            </li>
            <li class="nav-divider"></li>
        }

}
  • It worked perfectly, thank you very much @joaoeduardorf

  • 1

    Thanks, needing something gives a touch.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.