Try our conversational search powered by Generative AI!

The mysterious problem with WebResource.axd

Vote:
 
I have tried to figure out why a customer get a strange error message on their ASP.NET web site that stops the whole site from working until you restart the whole IIS. The exception “The WebResource.axd handler must be registered in the configuration to process this request” occurred quite randomly at first sight. After some investigations I found that the site usually stopped working if you called some of the pages immediately after a restart of the web application. This happens for example when you change in web.config but an unload of your AppDomain can be triggered by other mechanisms, too. I found no clues to the cause when I searched on the error message, only a lot of question and other desperate people. Looking closer at the call stack and browsning around with Roeders Reflector I found that the cause of our problem with WebResource.axd is in the method EnsureHandlerExistenceChecked in the class System.Web.Handlers.AssemblyResourceLoader: http://blog.fredrikhaglund.se/files/2007/09/ensurehandlerexistencechecked.PNG As you can see in the code above, if the test fails once it will never re-test since handlerExistenceChecked is true and the site will stop working forever. This check is called for several reasons. One of them is because components like the RequiredFieldValidator uses the ClientScriptManager to insert links on the page to JavaScript that is embedded inside a resource in an assembly somewhere. To make the resource available from the browser the generated link contains a reference WebResource.axd that is registered as a HttpHandler in machine.config redirecting calls with that filename to the AssemblyResourceLoader class. The only way to recover from the error I have found is to stop the site, run iisreset /restart and wait for a while before you start the site again. I have not manage to find the exact reason for why the test fails initially. I have some theories but they are hard to validate since used classes and methods are private or internal. One guess is that FindMapping returns null because the HttpHandler collection has not yet been loaded. Another guess is that HttpHandlerAction has not been correctly initialized so TypeInternal is null. It could even be possible that there is a problem with the type system (because ASP.NET applications unloads the AppDomain, generat assemblies dynamically and loads them, etc) so you actually have two instances of the same underlying system type making the Equal operator give an incorrect result. It really does not matter why it does not work since we can not patch Microsoft’s framework ourself or wait for a hot fix. If anyone else has some clues or have done some research on this problem, please let me know! My workaround to recover from the error is to use reflection to clear one of the private static flags so it re-runs the test. (Use of reflection like the requires that your application does not run with a low trust level so it might not work everywhere.) Since it is expensive to use reflection I only run the check in the Error event handler in my Application object. http://blog.fredrikhaglund.se/files/2007/09/workaround.PNG Any feedback is appreciated, see comments in my blog: http://blog.fredrikhaglund.se/2007/09/27/the-mysterious-problem-with-webresourceaxd/
#15793
Sep 27, 2007 1:17
Vote:
 
Hi Fredrik! I just wanted to inform you that we have seen this problem on a few occations and have it on our todo-list. As you say, it seems to fix itself when the application is restarted.
#16381
Sep 27, 2007 11:36
Vote:
 
Is there any fix solving the problem described in this thread?
#16382
Nov 27, 2007 11:10
Vote:
 
Hi, Just wondering if there was any update on when/if this issue is going to be fixed? We are having the same issue, mainly when people are accessing the login page, which causes a problem when the users are trying to update the content. As the site is a press release site, and people are updating the content all the time, this is a really big problem. I have seen Fredricks fix to the issue, but I'm slightly worried that this might cause other issues, so was wondering if anyone else had tried this workaround? Thanks, Jim.
#16383
Mar 03, 2008 16:12
Vote:
 

Please read this post:

http://labs.episerver.com/en/blogs/per/Archive/2008/5/The-not-so-mysterious-problem-with-WebResourceaxd/

#19919
May 14, 2008 15:17
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.