It’s very common for a medium/large scale company to have
many websites. Users should be presented with the same look & feel in all
the websites for better user experience. Apart from that there are certain
files (images, styles, scripts etc) that need to be used in each website so,
there should be a mechanism to place such common files in one place and then
use them in all the websites. This will also help to maintain the applications
easily. If there are some changes required, just update the common file to
reflect the changes in all the websites. This article helps defining such common
Define Common Elements
Create an empty website project named ‘Common’ and
create/add the following items under it.
Create Master Page folder named ‘MasterPages’ for the layouts and add
common master page files.
Create Styles folder named ‘Styles’ and add multiple CSS files to hold
the common styles.
Create Images folder named ‘Images’ to place the commonly used images.
script files under this folder.
Place the above website under some common folder so that you
can refer them later on.
Use Common Elements
Create multiple websites and deploy them on IIS. Configure
the above defined website named ‘Common’ as a virtual directory in each of the
deployed website. Now you can refer the above defined master pages, CSS files,
from 'Common' virtual directory by just pointing to file that is placed under
the virtual directory. For example, in a website page you can point to a master
page named ‘CommonMaster.master’ file placed under Common website like this.
<%@ Page Language=”C#”
respectively as shown below
<link rel="stylesheet" type="text/css" href="~/Common/Styles/common.css"/>
<img alt="image" src="~/Common/Images/save.png"/>
For convenience while developing websites using Visual
Studio, you can configure the 'Common' website virtual directory in the derived
Moreover, 'Common' website can be used to place other common
files like company policy documents, user manuals etc.
Hope it helps!