1

I've created my ASP.NET web application using Identity 2 and have defined several roles. The role based authorization is in place. The controller class action methods have been decorated with Authorize commands specifying which roles can use that controller method.

At this point, I need to customize the Bootstrap 3 navigation menu so that only administrators see their menu options, only members of Role A see theirs etc. Back in the day, I used to use sitemap membership provider but am unsure how to do this in Plain Ole MVC 5. Guidance is much appreciated!

SidC
  • 3,175
  • 14
  • 70
  • 132
  • There are numerous options including using `@Html.Action()` in the layout that calls a controller method and returns a partial view of a menu based on the user role –  Mar 07 '16 at 06:55

1 Answers1

1

You can use the User.IsInRole() to render links conditionally.

@if (User.IsInRole("Admin"))
{ 
        @Html.ActionLink("Admin Dashboard", "Index", "Dashboard")
} 

This might help.

Community
  • 1
  • 1
Amanvir Mundra
  • 420
  • 1
  • 6
  • 20