“Only Content controls are allowed directly in a content page that contains Content controls”

Yesterday a misleading error happened. A custom layout was deployed using Features and WSP solution packages. Everything went well, but when browsing to a page using this new layout, this message appeared:

Only Content controls are allowed directly in a content page that contains Content controls.

image

Furthermore, SharePoint inserted this funny-looking content after our Content element:

I started googling and I found a blog post by Rich Finn that in essence has the same problem.

CAUSE

Apparently, when a unknown or misspelled tag is found in page layout, SharePoint adds the content type information in a XML fragment, between the <asp:Content> tags. However, in ASP.NET no additional tags are allowed as first-level children, beside Content. In our case we had one <asp:content> tag, which was misspelled.

SOLUTION

Ensure that the <asp:Content> tags are properly capitalized. SharePoint seems to freak out when <asp:content> tag is found. 😉

5 thoughts on ““Only Content controls are allowed directly in a content page that contains Content controls””

  1. Thanks a lot for this solution! Could not figure out why it was adding the content upon provisioning page layouts until I found this!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.