Mukarram Mukhtar

Share Master Page (intro)

In .NET 2.0 and later, you can create and add a master page in your web application to give a common look and feel in all the web pages across the application. For example you can make a master page and put the application header and footer, all the common Javascript, css files etc in it; then rest of the web pages can be master page’s content pages and will automatically get and share the same functionality. This feature works perfect but what if you work in a corporate where instead of having one big giant enterprise level application you have a number of small, easy-to-handle web applications and you want a common shared master page for all of them? So in other words, we know a master page can be shared among different web pages in the same application, but can it be shared among pages of different web applications as well?

The answer is Yes, and No; a master page can be shared across different web applications but to what extent and at what cost and effort, is questionable. In order to achieve this functionality, there are 3 ways:

  1. Use of virtual directories
  2. Use of virtual path provider classes
  3. Use of precompiled code

And I discovered one or two other ways as well that are basically combinations of the above basic patterns. Each of the above approaches has its own pros and cons and you have to decide which pros are important for you and which cons you can live with. Let’s see each of them in detail and let’s get started with the first one, virtual directories.

Before we start actual work, please understand following two terminologies that I’ll use in these tutorials:

‘Master page project’ means: The project which has the master page and is shared by some other web applications.

‘Client web application’ means: The project which is having the reference of master page project and is sharing master page with some other client web apps.

 

References:

http://msdn.microsoft.com/en-us/library/aa992039(VS.80).aspx
http://msdn.microsoft.com/en-us/library/aa479564.aspx#vs05reu_topic6
http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualfile(VS.80).aspx
http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider(VS.80).aspx

Advertisements

1 Comment »

  1. REally helpful article

    Comment by Parag — April 26, 2012 @ 7:58 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: