Question

I have a standard menu using ul and li tags. And in my database, I have a table Users with a field 'certificate' and depending the value of this 'certificate', the user will see or not some items of the menu.

I was reading some texts and I think I will have to use ActionFilters. Is this right?

So, how can I render different menus depending which user is accessing?

thanks!!

Was it helpful?

Solution

Check out the Html.RenderAction methods that the futures assembly introduces. They can let you, in a very clean fashion, render an action method. This means that you can have a MenuController (for example) that takes care of all of the logic about what menu items you can render. Then it can just pass a simple data structure to the view, whose responsibility it is to render that data structure. Very clean.

OTHER TIPS

I would consider using RenderPartial or RenderAction instead. ActionFilters are not quite suited to that kind of thing. Take a look at this article.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top