Asp – MVC Web Application Database Driven Menu by User Permissions

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!

Best Solution

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.