I have an application which has a master page and child pages. My application is working fine on local host (on my intranet). But as soon as I put it on a server that is on the internet, I get the error shown below after clicking on any menus.
Only Content controls are allowed directly in a content page that contains Content controls.
Double and triple check your opening and closing Content tags throughout your child pages.
Confirm that they
I had exactly the same issue. The problem was I had some spaces after the ending content tag:
</asp:Content>
Remove all the spaces, line breaks after the last closing tag.
I was facing a similar issue. Are you surrounding your code with the "content" tag ?
<asp:Content>Add your HTML here</asp:Content>
And have separate content tags for your sections . A head content for the header declaration and a body content for the body declaration .
Another possibilty is line endings. I copied an older version of code from source control which enforced Unix style line endings. Since it wasn't a checkout, it didn't automatically convert the line endings to the DOS/Windows style. The error message was the "Only Content controls are allowed directly ..." error even though the page was layed out properly. It appears that the lack of Windows style line breaks caused the ASPX parser to fail.
I was able to fix it by pasting the code into a line ending agnostic editor (which caused the line endings to be normalized to the Windows style), re-copying it to the clipboard and pasting it back in Visual Studio, after which the page processed without errors.
In the case presented by Tripati Subudhi in the question, it's entirely possible that something about the deploy process used inadvertently converted line endings to the Unix style, leading to the error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With