

This is best view of architectural differences in 2007 to 2010





When we have requirements of customizing the site master page it can be done easily by editing master page using SharePoint designer as per our requirement. When we set the customized master page to a site, the site pages render with new master page but application or system pages render with Applicaton.master page. In this situation the changes we have done with custom master page mismatches with application .master page.
To bring uniformity to over all pages in site we have to modify the application master page as like custom master page.
It can be done with following way.
Step 1. Create the custom module for redirecting the control to custom Application master page from default Application. Master page at runtime.
using System;
using System.Web;
using System.Web.UI;
using System.IO;
namespace MyHttpModule
{
public class MyCustomHttpModule: IHttpModule
{
public void Init(HttpApplication context)
{
context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute);
}
void context_PreRequestHandlerExecute(object sender, EventArgs e)
{
Page page = HttpContext.Current.CurrentHandler as Page;
if (page != null)
{
page.PreInit += new EventHandler(page_PreInit);
}
}
void page_PreInit(object sender, EventArgs e)
{
Page page = sender as Page;
if (page != null)
{
if (page.MasterPageFile != null)
{
if (page.MasterPageFile.Contains(“application.master”))
{
page.MasterPageFile = “/_layouts/MasterPages/Custom.master”;
}
}
}
}
public void Dispose()
{
}
}
}
Step 2 – Register the module
Note a few things:
Step 3 – Put a custom master page in the layouts folder
In Step 1 we told the code to look for the master page in /_layouts/MasterPages/Custom.master. Thus, we need to actually have a master page there.
Step 4 – Make changes to the Custom.master
Now that you have built an HttpModule to redirect to the Custom. Master page you can customize your Custom. master page however you want. But, you still have to be careful about keeping the content place holders around per the articles I have been writing in this series.









