How are you supposed to conditionally display menu items based on roles in the Bootstrap Sample project? I was thinking of doing the following
- Implement
INavigatonRouteFilter
- really just implementing theshouldRemove(Route navigationRoutes)
method - by getting the default controller/action for the route and seeing if the user is authorized - Call
NavigationRoutes.Filters.Add(myAuthorizationFilter)
after configuring theNavigationRoutes
inApp_Start
There are two problems I see with this approach:
- I don't actually know how to do the first step unless I add in a bunch of conditional statements to check for
Controller
's name explicitly - This seems like it could make
NavigationRoutes.Filters
very hard to deal with once there are a lot of filters or a desire for more modularity later on
I don't know that I've explained the problem clearly enough, but basically I want to use what is provided in the Bootstrap sample to implement authorization-based navigation menu display if at all possible. Using INavigationRouteFilter
just seemed like the most natural way to do so.