Geeks With Blogs
Sandu's Blog Views on life as a techie


In my company we have an architecture where we have several websites working together to form one big application. We use the same MasterPage and Theme for all the websites so that they look like the same application. We do this since this allows us to customize our applications based on clients by plugging in different functionality provided by different websites. We also have different Masterpages for different clients and load the correct one dynamically once the user logs in.

One problem we've been having is that we have copies of the Masterpage files in all the websites. Recently I found a good solution to this problem in Piush Shah's blog. This is by using the VirtualPathProvider of .NET 2.0 to load Masterpage from a different location such as a dll. So this dll can be common to all applications and can contain all the different masterpages we want to load. By doing this we can save effort in maintenance because there is only one copy of the MasterPage file. We can use any other path to load the file from such as database, shared file pah, etc.

This is done by writing an implementaion to the VirtualPathProvider class and registering it in the Application Load event. If we dig deeper we can see that the default behaviour ASP.NET also uses an implementation of the VirtualPahtProvider which is MapPathBasedVirtualPathProvider, which maps the url path to a file system path.

Posted on Tuesday, December 9, 2008 2:57 PM | Back to top

Comments on this post: Share MasterPage across applications

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Sandaruwan Fernando | Powered by: