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

Topics: ASP.NET 2.0, Controls
Apr 10, 2010 at 3:48 AM

Hi Guys,

 

I'm receiving this error since yesterday and am unable to figure out the cause

 

 

Error Details:

Url : http://www.mayankraichura.com/default.aspx

Raw Url : /Default.aspx

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

Source : System.Web

StackTrace : at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)

at System.Web.UI.TemplateParser.ParseReader(StreamReader reader, VirtualPath virtualPath)

at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath)

at System.Web.UI.TemplateParser.ParseInternal()

at System.Web.UI.TemplateParser.Parse()

at System.Web.UI.TemplateParser.Parse(ICollection referencedAssemblies, VirtualPath virtualPath)

at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType()

at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)

at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()

at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()

at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)

at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)

at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)

at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert)

at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)

at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)

at System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)

at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)

at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

TargetSite : Void ParseString(System.String, System.Web.VirtualPath, System.Text.Encoding)

.

 

Please help....

Coordinator
Apr 10, 2010 at 5:57 AM

This looks like an ASP.NET error -- meaning, there's nothing specific to BE from what I can tell.

Google has a lot of hits for that error message:

http://www.google.com/search?q=Only+Content+controls+are+allowed+directly+in+a+content+page+that+contains+Content+controls

Apr 10, 2010 at 9:56 AM
Thanks Ben. Well I know that this is a common ASP.Net error but this
error has occurred by itself. I mean, the error occurs even if i use a
different theme. And surely, I haven't changed a single file since a
month or two. All major admin pages except for "Comments" (BE1.6) are
working fine.
Coordinator
Apr 10, 2010 at 10:33 AM

I just mean that you'll probably have a better chance trying to figure this out via Google, to see what others with this error have done ... or at least try to figure out what causes the error.

I personally don't remember seeing this error, and the stack trace you posted (thanks for posting) isn't really pointing to anything BE specific.  Maybe a BE user who has run into this error will see this and give us a hint.

Apr 12, 2010 at 7:09 AM
Edited Apr 12, 2010 at 7:12 AM

Hey All,

 

Sorry if I'm disturbing you again, but I am really stuck.

The weird thing is when I access default.aspx directly!

 

These links are working just fine???

http://www.mayankraichura.com/post.aspx?id=b9a64ca9-ac78-45fc-b89b-ce4f9c36fbf5

http://www.mayankraichura.com/post.aspx?id=bc98b927-8d94-4486-9dfb-4e1a90ea8078

and so are the rest of the posts. But when I try to access the page via www.mayankraichura.com, it is displaying the error.

Any ideas?

 

PS: default.aspx from freshly downloaded zip file resolved the issue....don't know what cause the error!!!!

Aug 8, 2013 at 6:34 PM
I just had the same issue. Site started crashing with this error on just the home page, and just with my hosting provider (no error running the same code locally).

Just uploading default.aspx again got the site working.
Aug 8, 2013 at 8:28 PM
Edited Aug 9, 2013 at 10:35 AM
Hi abfo,

Although, the reply is non-specific, here is what I've believe to be the cause of the issue.

I've learned from my experience, long after the above error was posted, that the reason for the cause of error is in plain sight. That there is some code that should not have been there in the first place. This kind of error occurs when your aspx file gets infected with malicious code either due to weak FTP password or a server-wide vulnerability and the virus/hacker/malicious code is affecting default pages (this is quite common with PHP pages).

Normally, the malicious code, which may be in the form of a Javascript tag used to inject more malicious code into the webpage, is appended to the bottom of the default file (default.htm, default.aspx, index.html, index.html etc) ensuring that the malicious code is executed almost everytime. Since, ASP.Net doesn't allow even a single character outside the Content tag (when it is inheriting from a Master Page), it raises the error Only Content controls are allowed directly in a content page that contains Content controls.

Hope this helps in understanding the cause of error.
Coordinator
Aug 8, 2013 at 9:20 PM
This actually very interesting and explains issue perfectly, thanks for bringing it up.
Aug 8, 2013 at 9:22 PM
I wish I'd looked on the server before overwriting the file now. I'll file a ticket with my hosting provider and see if I can get a look at a backup. Thanks for the suggestion NoisySilence.