Hey all, we ran across kind of a funny situation this week so I thought I would share with you what we saw and what you need to know.
We were working on customizing the master page using a feature to deploy the master and feature receiver to actually set the master page for the site to our custom master page. Normally what you should expect is, if you're working with an SPWeb object, you want to change the CustomMasterUrl property to change the master page used for end user pages. To change the system master page (i.e. pages that are served from the _layouts directory, the Forms folder for list and libraries, etc.) you want to change the MasterUrl property. All of that works fine and good, in much the same way as I described back in 2007 in my posting for customizing My Sites (http://blogs.msdn.com/b/sharepoint/archive/2007/03/22/customizing-moss-2007-my-sites-within-the-enterprise.aspx). So here's the thing that's kind of funny.
In all of the sites we tested, the rules I just described above (for CustomMasterUrl vs. MasterUrl) are correct. However, when you are creating a personal site, i.e. My Site, i.e. a site based on SPSPERS template, it still uses the SharePoint 2007 style settings for changing the master page. So that means you do the opposite of what I've just described. You set the MasterUrl property of the SPWeb in order to change the master page for end user pages in personal sites. Fortunately you can check which template your site is based on in the FeatureActivated event for an event receiver by checking the WebTemplate property of the SPWeb.
Thanks as well to Sean for helping to diagnose and track this down.
<p>I working to on site branding in sharepoint 2010. I want to set custom master pages for both CustomMasterUrl pages for end users and for site master page pages like _layout pages. but only custommasterurl is showing for all the end user pages and layout pages.</p>
<p>how to set different custom master pages for both enduser pages and layouts pages.</p>
<p> Uri siteMasterUri = new Uri(web.Url + "/_catalogs/masterpage/Sample.master");</p>
<p> Uri sysMasterUri = new Uri(web.Url + "/_catalogs/masterpage/CustomSystem.master");</p>
<p> web.CustomMasterUrl = siteMasterUri.AbsolutePath;</p>
<p> web.MasterUrl = sysMasterUri.AbsolutePath;</p>
<p> Thanks in advance</p>
<p>Oh its been bothering me since last year when i left israel for US. It's a long story and a lot of mystery.</p>
<p>I cant understand but as i opened my new pc its not like what i expected its ok when i set it for first use, after a week the program of windows seven home premium disappear. My 3rd pc in the us turned to be a continuation of my 1st to 4th HP pc. I believe i created "my site" just for curiosity. Losing a $500 in my bank account in israel. But i never had a clue before. What i know is that miracles happen since i opened a yahoo account late of 2007. Another big miracle happened when i bought my first pc early of 2008. Would you believe that i was using a celphone sending my article just using my cp? My friends who has a better cp cannot browse the internet or send an e-mail during that time. I have all the proof if you need to know if im telling you the truth or not. But a lot of unvelievable things happened to me in connection with computers. I am ready to cooperate. As my computer told me, i authored the last program that makes computers act the way they are now. I just cant believed it either. I lost my norton and macafee antivirus but when i opened my facebook, the norton was there. Every program i delete were transferred to other computers. Believe me i hate those templates which was added in my nokia phone eversince. I just want to make myself clear. I never intended to be a hacker like my computer ask me everytime i want to set it in factory settings. I have a lot more to tell but let me try to cure "my site".</p>