Using a Base Controller for obtaining Common ViewData

I am working on an ASP.NET MVC application that contains a header and menu on each page. The menu and header are dynamic. In other words, the menu items and header information are determined at runtime.

My initial thought is to build a base Controller from which all other controllers derive. In the base controller, I will obtain the menu and header data and insert the required information into the ViewData. Finally, I will use a ViewUserControl to display the header and menu through a master page template.

So, I'm trying to determine the best practice for building such functionality. Also, if this is the recommended approach, which method should I override (I'm guessing Execute) when obtaining the data for insertion into the ViewData.

I'm sure this is a common scenario, so any advice/best-practices would be appreciated! Thanks in advance!

EDIT: I did find the following resources after posting this (of course), but any additional anecdotes would be awesome!

http://www.singingeels.com/Blogs/Nullable/2008/08/14/How_to_Handle_Side_Content_in_ASPNET_MVC.aspx

http://stackoverflow.com/questions/326987/how-do-you-use-usercontrols-in-aspnet-mvc-that-display-an-island-of-data

Answers


Depends on where your information is coming from. We have standard view data that we use to generate some of the information we have on screen that we create in just this fashion. It works well and is easily maintained. We override the View method to implement strongly typed view names and use this information to retrieve some of the data that the master page requires as well.


Need Your Help

How to use a camera in Corona Simulator?

camera lua simulator corona

I'm wondering how to use a camera in Corona Simulator. I want to test my app (which requires a camera) out on the simulator but i don't know how to enable usage for a camera. Is there anyway to set...

How to avoid merge-commit hell on GitHub/BitBucket

git github bitbucket

We're ending up with a lot of commits like this in our repo:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.