views:

655

answers:

2

We are going to port a legacy windows app to a large web application for a vertical market. Looking at MVC. Each implementation may have 50 to 5000 users. Looking at putting navigation in Master Page. The application will contain 200 to 300 menu items, resulting in over 500 views. We want to display a trimmed navigation menu for each user based on their application permissions. A user may see only 20 items, or all available.

Most posts I have seen suggest passing navigation items to Master Page through viewdata, established in a base controller class. I understand this.

Each of the potentially 10's to 1000's of users will have a different set of permissions.

Does anyone have any solutions that will avoid hitting the database to get the users menu items on every controller request that inherits from the base controller?

Is there a caching scheme that will work for each user?

Should the navigation be handled in a frame (not my choice)?

Is this just a price we will pay for this approach to navigation?

Thanks for any input!

+1  A: 

You could start by caching linq queries which would be a nice way to tackle this at the DB tier.

Doing this in MVC using an action filter wouldn't be too hard either.

I implemented something like this in PHP a year ago but the general idea is the same. Firstly, you'll need to assign each menu configuration a unique id. This way when user A and user X request the same menu configuration, it resolves to the same cache file.

The first time a menu needs to be loaded for the user, it is loaded from the database and passed to the user. Simultaneously, it is saved to a cache file with the unique id in its name. On subsequent requests the action filter can load the data from the cache file if it exists and bypass the database.

aleemb
Thanks for the response. I am putting together a test app to try this out.
SY
+1  A: 

Some ideas:

1.) You could have your nav bar html come from a Html.RenderAction (MVC Futures) and use the Output cache on that.

2.) You could generate the html for the nav bar per user then save that to the DB and regenerate if their user permissions change. So all you would need to do is pull the html from the DB against each users record.

Mark Perry
Thanks, I thought about option 2 as we have stored html in the db for other purposes. I will have to try this out also. If I store the html in the db, it looks like I can do a html.renderpartial and then cache the partial?
SY