views:

138

answers:

2

Hi everyone!

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 ActionFiltes. Is this right?

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

thanks!!

+1  A: 

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

Mauricio Scheffer
+1  A: 

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.

Joel Martinez
I've downloaded the futures assembly but I can't make it work. It's only showing RenderPartial... nothing about RenderAction
AndreMiranda
You need to add <add namespace="Microsoft.Web.Mvc"/> to the pages / namespaces node in web.config. That will bring in the additional features and extension methods from futures
Joel Martinez