Last night we came across a strange issue when updating a Publishing sites MasterPage. We have deployed the MasterPage through a SharePoint Feature, and wanted to upgrade the MasterPage. Only a small addition had been made, but because the solution contained a lot more changes that had not been tested yet, we opted to change the MasterPage through SharePoint Designer. We would then, after the solution had been fully tested and upgraded, restore the MasterPage back to the site definition and all would be well. We were wrong.
As soon as we changed the MasterPage through SharePoint designer, the site started throwing ‘The type is not registered as safe’ errors. Which is weird, because we did not change a thing that was remotely related to this error message. When resetting the MasterPage back to the site definition, everything was working fine, even though the web.config had not changed at all. After puzzling for several hours we figured it out.
When you change a MasterPage in any way outside of the solution, SharePoint automatically creates an un-ghosted copy of this MasterPage. When doing so, the page is now being checked by the SafeMode parser, instead of the ASP.Net parser. The SafeMode parser ensures all controls referenced on the MasterPage are listed as safe control in the web.config. In our case it wasn’t, which caused the un-ghosted MasterPage to throw an error.
In order to fix this error, you can revert the MasterPage back to its ghosted condition by following these steps:
- Go to Site Settings
- Go to Reset to Site Definition
- Fill in the complete URL to the MasterPages’ location, and hit OK
Unfortunately for us this meant that we could not simply update just the MasterPage and had to wait for the entire solution to be tested before we could implement the new MasterPage.
A very good link to use for the difference between ghosted, unghosted and ghostableinlibrary can be found here: http://magenic.com/Blog/GhostedUnghostedandGhostableInLibrary . The difference between the ASP.Net parser and the SafeMode parser can be found in great detail here: http://www.bluedoglimited.com/SharePointThoughts/Lists/Posts/Post.aspx?ID=4