The not so mysterious problem with WebResource.axd

by: Per Bjurström

Please read this post by Fredrik for the background. There is also a thread in the EPiServer forums here.

So, this problem got highest priority due to a increasing number of customers experiencing this problem. I've been live debugging EPiServer CMS and ASP.NET code today which finally led to me to the cause of the problem, it is actually very cool to be able to set break points in the source code from Microsoft and modify private variables to trigger error conditions.

I found the cause pretty quickly after I found out that the forms authentication calls into the resource loader, the next step was to trigger a request for a file without the handler for WebResource.axd registered.

Repro

1) Forms authentication enabled (because FormsAuthenticationModule.OnEnter calls into AssemblyResourceLoader.IsValidWebResourceRequest)

2) Trigger a restart of the web application (save web.config, iisreset etc)

3) First request must be on a path backed by a Virtual Path Provider (or other location without the WebResource.axd registered). FormsAuthenticationModule will cause the initialization of AssemblyResourceLoader.EnsureHandlerExistenceChecked to be run under a context where WebResource.axd is not registered.

4) Open a ASPX that requires a web resource, it will crash with error “The WebResource.axd handler must be registered in the configuration to process this request” even if a valid WebResource.axd registration exist for that path.

5) The problem will not go away until a restart of the web application is made.

 

Possible workaround

For each and every Virtual Path Provider add the WebResource.axd handler before the wildcard mapping to StaticFileHandler in EPiServer CMS, for example:

   1: <location path="VPPFolder">
   2:   <system.web>
   3:     <!-- Setup the StaticFileHandler for the wildcard mapping to work in IIS6 -->
   4:     <httpHandlers>
   5:       <add path="WebResource.axd" verb="GET" type="System.Web.Handlers.AssemblyResourceLoader" validate="True"/>
   6:       <add path="*" verb="GET,HEAD" type="EPiServer.Web.StaticFileHandler, EPiServer" validate="true" />
   7:     </httpHandlers>
   8:   </system.web>
   9:   <staticFile expirationTime="-1.0:0:0" />
  10: </location>

The fix

Its reported to Microsoft and I really hope that they will fix it as soon as possible, especially when .NET 3.5 SP1 is around the corner. I have a plain vanilla ASP.NET project to reproduce the problem also if someone is interested.

Update 2008-08-27: Microsoft says that they will not fix this for .NET 3.5, and its not in SP1. It would require to much changes in the their code base :-(

14 May 2008


Comments

  1. Nice! /Fredrik
  2. Thanks!!
  3. Hi there, I'm working on an in-house system and came across the same problem. I don't know much about IIS, but I did manage to get it working here. Dunno if any of this helps... 1. Am I right in thinking that IIS6 uses "system.web/httpHandlers", while IIS7 uses "system.webServer/handlers"? I found I was editing the wrong section at first. 2. If using IIS7, I found it much easier to use the IIS management console to edit the handlers, which writes back into the web.config file. 3. Putting those together, I places handlers for WebResource.axd and ScriptResource.axd above my all files handler, and everything seems to be running OK. (I deleted all the others too for cleanliness). Hope that helps, Stu
  4. Stu, you are right about the differences between IIS6 and IIS7.
  5. Thanks for the tip! Experienced the same problem today after a restart of IIS which has both EPi 4 webs and EPi 5 webs on it. Does anyone know the status of the bug since the update in August?
  6. Well, in CMS 5 we add the WebResource as part of the installer to work around the issue. The bug filed at MS can be found here: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=344473
  7. Should probably correct the casing on validate="True" in your example code there. Other than than, thanks for this one, we had this exact problem on a production site and was able to resolve it pretty fast after some googling which led us here...
  8. Hi, I've just faced this problem after adding a AJAX Control in a MVC View aspx. All other views and pages are working fine, except the one I'm using AJAX - and the ScriptManager. Here is part of my Web.Config file: I've tried your solution, as you can see above, but its not working. Another weird thing is happening. When I run the application from Visual Studio (like debugging), everything works fine. When I publish my application to server, the issue appears. Could you help me with this? What can you suggest to me? Thanks for your help, Mauricio
Post a comment    
User verification Image for user verification  
EPiTrace logger