Branding MOSS 2007 Application Pages

Based on research, there are 3 ways to brand the application pages.


  1. Backup all your layouts folder file into another folder (i.e. LayoutsBackup). Change the files (i.e. application.master) in the layouts folder to satisfy your branding. [This is recommeded by Microsoft]
  2. Create a brand new layouts folder (i.e. customLayouts) and change the IIS site settings for the SharePoint web application to point to the new customLayouts folder.
  3. Use a HttpModule to change the application page master page reference.

For more details, refer here.

Below is a simple HTTP Module that does it




using System.Web;
using Microsoft.SharePoint;
using System.Web.UI;


namespace Aymhi.MOSS.HttpModules
{
public class SharePointAppPageMasterPageModule : IHttpModule
{
public void Dispose()
{
throw new NotImplementedException();
}

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)
return;
if (page.MasterPageFile == null) return;
HttpContext context = HttpContext.Current;

if (context.Request.RawUrl.Contains("/_layouts/"))
page.MasterPageFile = "~/_layouts/CustomApplication.master"; //your custom application master page
}
}
}



You need to put the http module reference in web.config.


<add name="AppPageMasterPageChange" type="Aymhi.MOSS.HttpModules.SharePointAppPageMasterPageModule, Aymhi.MOSS.HttpModules, Version=1.0.0.0, Culture=neutral, PublicKeyToken=01e991839513c2f9"/>



Comments

Unknown said…
Great solution..It is working fine with all the pages except sitemanager.aspx page. could anyone please help

Popular posts from this blog

SharePoint 2013 App Details Page Error

SharePoint 2013 - Working with Display Template for Content Search Web Part

SharePoint 2013 Features Information List