views:

380

answers:

1

To simplify our SharePoint environment I am wanting to have a central and single location where all of the master pages are stored so I was hoping to reference the masterpage files directly from the _layouts directory.

I add the files to the "\LAYOUTS\MyMasterPages" directory and then update the SPWeb object to use that path:

web.MasterUrl = "/_layouts/MyMasterPages/newdefault.master"

But when I go to the site I get:

The referenced file '/_layouts/MyMasterPages/newdefault.master' is not allowed on this page. at System.Web.UI.TemplateParser.ProcessError(String message) at System.Web.UI.BaseTemplateParser.GetReferencedType(VirtualPath virtualPath, Boolean allowNoCompile)
at System.Web.UI.PageParser.ProcessMainDirectiveAttribute(String deviceName, String name, String value, IDictionary parseData) at System.Web.UI.TemplateParser.ProcessMainDirective(IDictionary mainDirective)

I am assuming that this may be due to trust level security policies and a CAS configuration but I am not entirely sure. Is there a way to allow this central way of using master pages across the enterprise or am I stuck using the /_catalog/ virtual path?

A: 

My understanding (but I don't know why) is that Master Pages need to be in the MasterPage gallery of each site collection.

Since you would need to deploy those packages to each SharePoint server (frontend, application, database, etc) in the farm, I think the requirement is either related to clustering, or perhaps to the database and ghosting.

In either case, be sure to use custom features as the way you deploy your master pages regardless of your farm size.

I understand the want to do things your own way with SharePoint, and while I am normally on board with that kind of thinking, the past year of pain has taught me that living inside of the recommended SharePoint boundaries is the best way to go.

MrChrister
It makes little sense limiting masterpages to a site collection level. I'm not sure why MS did this. It forces you to maintain the same file in multiple locations since no enterprise solution is going to be able to be limited to a single site collection. I'd like to find out the mechanisms that prevent you from doing it and then weigh my options.
webwires
I know what you are saying, but I do know that each site collection is a database instance. Again, while I don't know, I think there is a clue there.
MrChrister