Sdílet prostřednictvím


How to fix: Error in SharePoint when custom master page is applied

UPDATE: Found this get hit through our support channels several times last week. As it turns out, depending on the missing content placeholder (or other pieces), the cause of the error may be different than just creating new list items; like I previously stated. Therefore, I "genericized" my post to be more applicable to a wider-range of situations. Same steps apply to find what's causing the issue, though.  

Symptoms:

After changing to a customized master page, creating new items for several lists, along with several other operations, no longer works and result in an error message.

Error:

"An unexpected error has occurred."

Cause:

There may be several causes. One, is that the custom master page is missing necessary content place holders.

Resolution:

Method 1: Identify the missing content place holders by modifying the web.config.

  1. Browse to c:\inetpub\wwwroot\wss\virtualdirectories\[port of web application]. Note: in this folder you will find a web.config file.
  2. Open the web.config file in Notepad (or like-application).
  3. In Notepad, click Edit -> Find, enter "custom" (without quotes). Click Find Next. You should find the following node: <customErrors mode="On" />. Change mode from "On" to "Off".
  4. In Notepad, click Edit -> Find, enter "callstack" (without quotes). Click Find Next (change direction Up / Down, if needed). You should find the following node: <SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">. Change the CallStack attribute from "false" to "true".
  5. Save the web.config file, and perform an iisreset /noforce.
    • NOTE: After performing the above steps, attempt to reproduce the error in the web browser. The error message should be descriptive in terms of what content place holder is missing. Take note of the place holder name.
  6. Open the master page, and in code view add: <asp:ContentPlaceHolder id="PlaceHolderName" runat="server" />. Replace PlaceHolderName with that of the actual content place holder name that was shown in the error message from step 5.

Method 2: Find the missing content place holders manually.

  1. Open SharePoint Designer 2007. Go to File | Open Site and connect to SharePoint site.
  2. Expand out _catalogs -> masterpage -> open customized master page.
  3. Go to Code view. Go to Edit | Find.
  4. In the Find and Replace dialog, enter: "<asp:contentplaceholder" (without quotes). Click Find All.
  5. Reference the occurrences found in the file with that of available content place holders:
    • PlaceHolderBodyAreaClass
    • PlaceHolderBodyLeftBorder
    • PlaceHolderBodyRightMargin
    • PlaceHolderCalendarNavigator
    • PlaceHolderFormDigest
    • PlaceHolderGlobalNavigation
    • PlaceHolderHorizontalNav
    • PlaceHolderLeftActions
    • PlaceHolderLeftNavBar
    • PlaceHolderLeftNavBarBorder
    • PlaceHolderLeftNavBarDataSource
    • PlaceHolderLeftNavBarTop
    • PlaceHolderMain
    • PlaceHolderMiniConsole
    • PlaceHolderNavSpacer
    • PlaceHolderPageDescription
    • PlaceHolderPageImage
    • PlaceHolderSearchArea
    • PlaceHolderSiteName
    • PlaceHolderTitleAreaClass
    • PlaceHolderTitleAreaSeparator
    • PlaceHolderTitleBreadcrumb
    • PlaceHolderPageTitleInTitleArea
    • PlaceHolderTitleLeftBorder
    • PlaceHolderTitleRightMargin
    • PlaceHolderTopNavBar
    • PlaceHolderUtilityContent
    • SPNavigation
    • WSSDesignConsole
  6. Iteratively add any missing content place holders to the master page in the form of: <asp:ContentPlaceHolder id="PlaceHolderName" runat="server" />. Replace PlaceHolderName with that of the actual content place holder name.
  7. Save master page (Check In, and Approve if necessary) after each added content place holder, and test to see if error still occurs. 

NOTE: In SharePoint Designer 2007, go to View | Toolbars | Master page to bring up the master page toolbar. This may also help in identifying place holders currently used on the customized master page.

Additional Information:

I hope this helps some of you SharePoint branders out there running into similar problems. Certainly, there are few things more frustrating then finding out your beautiful and slick-looking master page is actually causing SharePoint to fail. With that said, I am interested in learning what kind of problems you've ran into with customized master page files with SharePoint, and how you resolved the issues.

Comments

  • Anonymous
    July 10, 2008
    PingBack from http://stevepietrek.com/2008/07/10/links-7102008/

  • Anonymous
    December 08, 2008
    This is such a common problem. We were tearing our hair out trying to work out why any number of things weren't working only to discover it all came down to a couple of missing placeholders and, more importantly, their position on the page. It didn't matter that we didn't require them, or even that they were hidden. There are clearly inscrutable goings-on behind the secnes that require these placeholders to exist. If they don't, many javascript checks fail and expected functionality is lost. In our case this primarily affected the appearance and proper use of image libraries but Jed knows what else was being affected. Simple lesson 1: don't use the minimal master page provided on MSDN. Hence the supplied link to heather Solomon's much improved version above. Simple lesson 2: Don't delete ANY placeholders. Place them all between an ASP panel wtih visibility set to false, usually somewhere near the end of your page but there is no hard and fast rule for this. <asp:Panel Visible="false" runat="server"> ... </asp:panel>  

  • Anonymous
    January 20, 2009
    I tried these solutions and they didn't work but I did come up with a workaround: My problem was I was editing on the site instead of locally. Publish the site to your hard drive.  Then open and edit the files locally and publish remotely. Once I did this I no longer had problems.

  • Anonymous
    December 19, 2009
    Thank you, this post helped to resolve my issue, but, one Content Place Holder is missing in the list. My custom master page was missing "PlaceHolderPageTitle". After adding PlaceHolderPageTitle content place holder, my master page worked fine. Regards, Kishore Dodda

  • Anonymous
    June 03, 2010
    I have all the place holders, however, my title of the website is still odd. This is the title : <SharePoint:EncodedLiteral runat="server" text="" EncodeMethod='HtmlEncode' __designer:Preview="Home" __designer:Values="<P N='Text' Bound='True' T='Resources:wss,multipages_homelink_text' /><P How do I fix this error?

  • Anonymous
    May 11, 2014
    "Identify the missing content place holders" NO. NO! IT SHOULD TELL US. What kind of an error message is this: "An error occured, here's a useless correlation number as technical un-info: sdjkl-fsdk-lfjsdf-sdfh????" Good luck with SharePoint Online PowerShell, when you get it to work! The error message should be: "Place holder with the name of "PLACE HOLDER NAME" is missing. Please add the place holder, PLEASE. Also, here's the markup for your convenience: <markup>" The error message should NOT be: "error happened." Anyways, I added a ton of ContentPlaceHolder with various names, and <sigh>... Ok, I'll just copy paste master page html everywhere.