.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Using HttpModule to change master page dynamically on SharePoint 2010 site

Posted By:      Posted Date: September 30, 2010    Points: 0   Category :SharePoint

I am trying to change master page dynamically on SharePoint 2010 site. I reviewed some documents (SharePoint: Dynamically Change Master Page: http://ranaictiu-technicalblog.blogspot.com/2009/10/sharepoint-dynamically-change-master.html) and I implemented IHttpModule, added it to GAC, modified web.config(safecontrol, httpmodule, module)
It works good! But I found some problems
1.Never catch the PreInit event for publishing pages
2."/_Layouts/RedirectPage.aspx" page occurred error
3.ContextMenu did not work

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using Microsoft.SharePoint;
using System.Configuration;
using Microsoft.SharePoint.ApplicationRuntime;

namespace MasterUtilModule
    public class MasterModule : IHttpModule
        public void Dispose() { }
        public void Init(HttpApplication context){

View Complete Post

More Related Resource Links

How to apply a custom master page to all the existing site collections, sub sites in sharepoint 2010



my custom branding master page is applying to the newly created site collection or sub sites using feature stapling.

but my intension is already created site collections and sub sites, here i am not able to apply custom master page to site collections and sub sites.

pls help me. i need to complete this task today EOD.

How to change master page in sharepoint 2010?

Hi All:

We've just got the sharepoint2010 installed to test it, like it so far, but many options that we were ablet o find quickly are now at different places, so I might be asking something very simple here that I just didn't see, could anyone point out for me where do I go to change master page in sharepoint 2010? it used to be under site settings -> looks and feels, but there is not this option under looks and feels in 2010, all i see about master pages is a gallery of what master pages there are. Thanks in advance.

Is there a site page default.master in SharePoint Server 2010??



I inserted a few lines of code on the wkpstd.aspx template to "show" the document library properties on each wiki page within each wiki page library. This is working fine, except that the property Document ID
is showing up on site pages as well.  I checked Moss 2007 and I foumd that there is a bpcf.aspx default page that is used to create a basic page. Is there a separate template or master page for the site pages within 2010 that i can modify?

Any help or suggestion is greatly appreciated. Thanks.


Set as default master page in Sharepoint Designer 2010 does not change pages at all


I make a copy of V4.masterpage ,rename it as myv4.masterpage, and modify it .

then right-click myv4.masterpage and choose 'set as default masterpage'.

but when i open my site, the pages don't change, and create a new page,it still the old look.


Shouldn't it do that?

change sharepoint site defult master page


Hi all,

i was trying to change default master to some other master page

here is wht i did.

opened site in moss designer

navigated to masterpage folder

and created a copy of default renamed it and made some changes

and then right click tht copy and set as default master

now when

i open site it says resource cannot be found whts wrong??

Sharepoint 2007 - Wiki site - New Pages Not Inheriting Custom Master Page


I am working on a SP site (MOSS not WSS) which is heavily customised away from the OOTB layout. I need to create a Wiki site, which was going well - I've created a master page which displays the miniconsole (this was not visible with our customised layout), and made it the default master page for the site. This has been applied to the two standard pages that come with the Wiki site, however when a new page is created, it seems to inherit the default.master, rather than my custom master page - thus not showing the miniconsole.

When I have created a new page, I am able to use SharePoint Designer to attach my custom master page to it, which works perfectly, however this will not be a viable option going forward as end-users create their new wiki pages.

How can I get the new pages to inherit my master page when they are created?


Adding a custom control to the SharePoint 2010 Team Site Wiki Page Template ( wkpstd.aspx ) programm

Topic This is maybe my last post about the Team Site Wiki Page customization with the aim of exceeding its limitations. This time we are going to customize the unique template ( wkpstd.aspx) by replacing the control that renders the editable content by a custom one. In this post example, we will take advantage of the use of this custom control to render not editable additional contents, for instance, a header and a footer that could be the same for a specific Wiki Page Library. Of course, we are not going to really customize the template, but we are going to use a delegate control to replace the control at runtime. Here are the screen shots of the result: We can see a non editable Header and Footer on the Team Site Wiki Page In edit mode these additional contents are not rendered, but we can add new content as usual And of course, after having saved the page, the new content is rendered wtih the non editable Header and Footer. Steps required   If you look at the Team Site Wiki Page template, wkpstd.aspx, you can see the control that is rendering the editable content/ <SharePoint:EmbeddedFormField ID="WikiField" FieldName="WikiField" ControlMode="Display" runat="server" /> We are first going to create a custom EmbeddedFormField control Then, we are going to use a delegate control to replace the native EmbeddedFor

replacing menu in a master page - Sharepoint Foundation 2010

I'm in the process of replacing a menu using Jquery and a sharepoint list.The menu data would be retrieved from webservice. But the problem i have is where to place my js menu script the master page. I tried disabling the asp: menu and the content place holders by setting visible to false and the place my div with the new menu just before the first content place holder. But i discover that any time i try and hover the menu.The hover kind of get blocked and it doesn't show. What do i need to take off and where should my js menu be place..

SharePoint 2010 new site collection display blank page

I'm using Windows Vista SP2 and trying to learn Sharepoint 2010. I'm new to Sharepoint and I'm sorry if I'm asking something very simple. I've successfully installed Sharepoint foundation 2010 and VS 2010. According to the installation instruction if the installation is successful I should see the new sharepoint website home page or ask for login info which will take to the home page. But for me it displayed a blank web page. I was able to get to Sharepoint Central administration page by clicking the browse option from IIS, it asked me login info and when I provided that I was able to see the Sharepoint central administration page. Now I am trying to create a new site collection, it is succesfully creating the new site collection and showing the link, but when I access the link I see a blank webpage. I think it is some permission issue and if the program prompts login, it should work, but how can I get to the login window or how can I see the home page and not a blank page? Thanks

Delete Page Layouts and Master Pages in SharePoint 2010

Hi I want to delete unwanted Page layouts and master pages in share point 2010. I tried to delete the steps mentioned below as like MOSS 1.Create a New folder 2.Move the page layouts to that New folder 3.Delete the New folder But this approach also failed.. please suggest me to delete... Thanks in Advance ArunWith Love

Search Master Page in SharePoint 2010

Hi guys,

When I create a site collection using the Enterprise Search Center template and then go in the Site Settings to change the Master Page I choose to inherit the master page from parent (subsite) or to use v4.master and confirm the default page layout is completely messed up, the search box disappears and it becomes unusable. I included screenshots of this issue below. please help me i am new to sharepoint Has anyone seen this before?

Before the Master Page update:

After the Master Page update:

.master page image is not shown in sharepoint site????


have build my .master page and uploaded it into sharpoint site all other constrols are shown on the master page on sharepoint site

but image is not visible on sharepoint site

can any body give me the solution about that!!!!!!

in sharepoint 2010

master page image not shown in sharepoint site


i have build my .master page and uploaded it into sharpoint site all other constrols are shown on the master page on sharepoint site

but image is not visible on sharepoint site

can any body give me the solution about that!!!!!!

in sharepoint 2010


Changing the master page and Css of SharePoint Site programatically

Hi All,

I am trying to change the Site Collection's Master page and alternative css  programatically. Below is the code I am using:


SPWeb spWeb = SPContext.Current.Web;

spWeb.AllowUnsafeUpdates =


spWeb.CustomMasterUrl = spWeb.CustomMasterUrl.Replace(

"default", "NewMaster");

spWeb.MasterUrl = spWeb.MasterUrl.Replace(


steps for creating a custom master page in SharePoint 2010



Can any one please help me out to prepare a custom master page in SharePoint 2010 designer and deploy it to SharePoint site.

i have a html page , which i want to put in my custom master page.

please help


How can I change the CSS file used in Master Page dynamically?


I am thinking that it would be better to use multipe CSS files and change them within the master page dynamically than it would be to use multiple master pages (basically one master page for each page, which defeats the purpose of the master page).

However, I do not know how to make a change to the master page before a standard apsx page that is derived from it is loaded.

IE 7 rendering issue in Sharepoint 2010 Master Page


Hi All,

I have an Branding issue, we designed a Custom Master page with Custom Css in Sharepoint 2010 Designer, it is rendering perfectly in all browsers as per design and css but, if we open in IE 7 design is distorted all the webparts are placed differently,

we used all Doctype tag

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 and <meta http-equiv="X-UA-Compatible" content="IE=7" /> also

we used DIV 's for this,

unable to find the solution please help me.

Thanks in advance


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend