1

A strange problem that's started happening recently.

I have an instance of Sitecore 8.0 setup (CD and CM separate servers).

A user uploads an image. (stored as blobs in the db) It shows in experience editor. when published to the web (same server) and viewed as the site it throws a 404 error.

The event viewer shows:

Exception information: 
Exception type: HttpParseException 
Exception message: "¹" is not valid at the start of a code block.  Only identifiers, keywords, comments, "(" and "{" are valid.

that tiny "1" is nowhere to be found in the code. If I publish to web-live it displays fine in that server.

Interestingly enough if I make the filename shorter it will load without error making me think its a max file path issue. Since its using the database this surely wouldn't be a windows issue limiting a file path length would it?

Has anyone dealt with anything like this before?

Thanks

EDIT

full error

3006 
   A parser error has occurred. 
   11/8/2018 2:53:55 PM 
   11/8/2018 2:53:55 PM 
   185e07226dd44282820f23549c46b33e 
   214501 
   134 
   0 
   /LM/W3SVC/2/ROOT-1-131842085429794370 
   Full 
   / 
   E:\Hosted\cms.website.org.uk\Website\ 
   HG-CORE-CM 

   3892 
   w3wp.exe 
   NT AUTHORITY\NETWORK SERVICE 
   HttpParseException 
   "¹" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid. at System.Web.WebPages.Razor.RazorBuildProvider.EnsureGeneratedCode() at System.Web.WebPages.Razor.RazorBuildProvider.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, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) at System.Web.WebPages.BuildManagerWrapper.CreateInstanceOfType[T](String virtualPath) at System.Web.WebPages.VirtualPathFactoryManager.CreateInstanceOfType[T](String virtualPath) at System.Web.WebPages.WebPageHttpHandler.CreateFromVirtualPath(String virtualPath, IVirtualPathFactory virtualPathFactory) at System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache(HttpContextBase context) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)  
   http://cms.website.org.uk/~/media/Images/Corporate/Enterprise-and-Development/Innovation-Village/General-Images/sitecore_media.ashx/~/media/Images/Corporate/Enterprise-and-Development/Innovation-Village/General-Images/featureintromap.ashx 
   /~/media/Images/Corporate/Enterprise-and-Development/Innovation-Village/General-Images/sitecore_media.ashx/~/media/Images/Corporate/Enterprise-and-Development/Innovation-Village/General-Images/featureintromap.ashx 
   148.253.178.66 
   sitecore\admin 
   True 

   NT AUTHORITY\NETWORK SERVICE 
   229 
   NT AUTHORITY\NETWORK SERVICE 
   False 
   at System.Web.WebPages.Razor.RazorBuildProvider.EnsureGeneratedCode() at System.Web.WebPages.Razor.RazorBuildProvider.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, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) at System.Web.WebPages.BuildManagerWrapper.CreateInstanceOfType[T](String virtualPath) at System.Web.WebPages.VirtualPathFactoryManager.CreateInstanceOfType[T](String virtualPath) at System.Web.WebPages.WebPageHttpHandler.CreateFromVirtualPath(String virtualPath, IVirtualPathFactory virtualPathFactory) at System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache(HttpContextBase context) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)  

below is the error directly from site Sitecore log file:

6148 16:30:51 ERROR Application error.
Exception: System.Web.HttpParseException
Message: "¹" is not valid at the start of a code block.  Only identifiers, keywords, comments, "(" and "{" are valid.

Source: System.Web.WebPages.Razor
   at System.Web.WebPages.Razor.RazorBuildProvider.EnsureGeneratedCode()
   at System.Web.WebPages.Razor.RazorBuildProvider.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, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
   at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
   at System.Web.WebPages.BuildManagerWrapper.CreateInstanceOfType[T](String virtualPath)
   at System.Web.WebPages.VirtualPathFactoryManager.CreateInstanceOfType[T](String virtualPath)
   at System.Web.WebPages.WebPageHttpHandler.CreateFromVirtualPath(String virtualPath, IVirtualPathFactory virtualPathFactory)
   at System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache(HttpContextBase context)
   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

1540 16:30:51 ERROR Breadcrumb:Error
ManagedPoolThread #7 16:30:52 INFO  Job started: Sitecore.ListManagement.Analytics.UnlockContactListsAgent
ManagedPoolThread #7 16:30:52 INFO  Job ended: Sitecore.ListManagement.Analytics.UnlockContactListsAgent (units processed: )

what makes me wonder about the length is that I've put image names scotttest up. when I visit it at

http://cms.website.org.uk/~/media/Images/Corporate/Enterprise-and-Development/Innovation-Village/General-Images/Scotttest.ashx it redirects me to

http://cms.website.org.uk/system/404?aspxerrorpath=/~/media/Images/Corporate/Enterprise-and-Development/Innovation-Village/General-Images/sitecore_media.ashx/~/media/Images/Corporate/Enterprise-and-Development/Innovation-Village/General-Images/Scotttest.ashx

If I try to access an image that absolutely doesn't exist: I get redirected to: http://cms.website.org.uk/system/404

now if I rename scotttest to scotttes (or anything shorter then that) then the image loads fine.

EDIT

still stuck with this one, made some interesting discoveries though. if the length of the image name is between 9 and 23 characters inclusive I get the 404 redirect error. if the image name is 8 characters or less or is 24 characters or more it loads fine. what on earth would cause something like this and where do I even look at to debug this? short of someone sabotaging the project with some evil if statements I'm at a complete loss!

7
  • What is the path to your website? When Sitecore renders your image, it pulls a copy from the database and creates it as a file in a local cache directory (yourwebsite\App_Data\MediaCache\website). Since it uses GUIDs as the filenames, maybe it is a file path issue. Nov 8, 2018 at 18:03
  • Also, can you add the full stack trace from the error logs, too? Nov 8, 2018 at 18:04
  • added the full error (replacing the main site actual url)
    – Box
    Nov 8, 2018 at 18:36
  • Is there any more detail in the Sitecore logs? Nov 8, 2018 at 18:42
  • Note 100% sure that this will help you, but i would try to look at the path length - in Windows. Try to check this out also: docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file. Also as in the comments - please add some more log info from whatever logs you have - sitecore logs to start with. Nov 9, 2018 at 13:16

2 Answers 2

2

found the solution!

in the root of my site there was a 5kb png file named: "NOT_A_VALID_FILESYSTEM_PATH" removing that fixes everything. seems its a known bug within sitecore after googling this specifically!

0

Look at your request path:

/~/media/Images/Corporate/Enterprise-and-Development/Innovation-Village/General-Images/sitecore_media.ashx/~/media/Images/Corporate/Enterprise-and-Development/Innovation-Village/General-Images/featureintromap.ashx

That looks wrong, looks like two media paths concatenated. I'm guessing your page code is generating this bad path. I've seen this sort of thing from using a "page-relative" (no leading "/") URL in e.g an <img src="">, when you need a "site-relative" (with leading "/") URL.

Edit:

Now that you've posted your Sitecore log error:

Looks like you're having two problems. One is that your media request isn't working. But #2 is your HttpParseException error, which is an error in cshtml parsing. I'm guessing that your 404 page is a cshtml page, and the HttpParseException is thrown by a syntax error in your 404.cshtml.

3
  • yeah thats the path i get redirected to for some reason. so if I visit: cms.website.org.uk/~/media/Images/Corporate/… and it will redirect me to: cms.website.org.uk/system/404?aspxerrorpath=/~/media/Images/… however if I rename the file from scotttest to scotttes (or shorter) it will load fine
    – Box
    Nov 9, 2018 at 17:16
  • made an interesting discovery. if the length of the image name is between 9 and 23 characters inclusive I get the 404 redirect error. if the image name is 8 characters or less, or is 24 characters or more it loads fine. what on earth would cause something like this and where do I even look at to debug this? short of someone sabotaging the project with some evil if statements i'm at a complete loss!
    – Box
    Nov 15, 2018 at 18:02
  • I'm rather surprised there's no error in the Sitecore log, right before the "HttpParseException" you posted, when the media request fails. Nov 15, 2018 at 22:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.