<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fredrik Haglund's blog &#187; WebResource.axd</title>
	<atom:link href="http://blog.fredrikhaglund.se/blog/tag/webresourceaxd/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fredrikhaglund.se</link>
	<description>Chatter about EPiServer, ASP.NET, CSS and Web Development.</description>
	<lastBuildDate>Thu, 15 Apr 2010 09:14:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The mysterious problem with WebResource.axd</title>
		<link>http://blog.fredrikhaglund.se/blog/2007/09/27/the-mysterious-problem-with-webresourceaxd/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2007/09/27/the-mysterious-problem-with-webresourceaxd/#comments</comments>
		<pubDate>Wed, 26 Sep 2007 22:20:27 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[WebResource.axd]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/?p=41</guid>
		<description><![CDATA[UPDATE: Solution to WebResource.axd exception
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 &#8220;The WebResource.axd handler must be registered in the configuration to process this request&#8221; occurred quite randomly at first [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE: </strong><a title="Permanent Link to Solution to WebResource.axd exception" rel="bookmark" href="http://blog.fredrikhaglund.se/blog/2008/08/26/solution-to-webresourceaxd-exception/"><span style="color: #006a80;"><strong>Solution to WebResource.axd exception</strong></span></a></p>
<p>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.</p>
<p>The exception &#8220;<em>The WebResource.axd handler must be registered in the configuration to process this request</em>&#8221; 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 <em>AppDomain</em> can be triggered by other mechanisms, too.</p>
<p>I found no clues to the cause when I searched on the error message, only a lot of question and other desperate people.</p>
<p>Looking closer at the call stack and browsning around with <a href="http://www.aisto.com/roeder/DotNet/">Roeders Reflector</a> I found that the cause of our problem with <em>WebResource.axd</em> is in the method <em>EnsureHandlerExistenceChecked</em> in the class <em>System.Web.Handlers.AssemblyResourceLoader</em>:</p>
<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/ensurehandlerexistencechecked.PNG"><img src="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/ensurehandlerexistencechecked.PNG" alt="EnsureHandlerExistenceChecked()" /></a></p>
<p>As you can see in the code above, if the test fails once it will never re-test since <em>handlerExistenceChecked</em> is <em>true </em>and the site will stop working forever.</p>
<p>This check is called for several reasons. One of them is because components like the <em>RequiredFieldValidator</em> uses the <em>ClientScriptManager</em> 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 <em>WebResource.axd</em> that is registered as a <em>HttpHandler</em> in <em>machine.config</em><strong> </strong>redirecting calls with that filename to the <em>AssemblyResourceLoader</em> class.</p>
<p>The only way to recover from the error I have found is to stop the site, run <em>iisreset /restart</em> and wait for a while before you start the site again.</p>
<p>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 <em>FindMapping </em>returns null because the <em>HttpHandler </em>collection has not yet been loaded. Another guess is that <em>HttpHandlerAction </em>has not been correctly initialized so <em>TypeInternal </em>is null. It could even be possible that there is a problem with the type system (because ASP.NET applications unloads the <em>AppDomain</em>, 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.</p>
<p>It really does not matter why it does not work since we can not patch Microsoft&#8217;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!</p>
<p>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 <em>Error </em>event handler in my <em>Application </em>object.</p>
<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/workaround.PNG"><img src="http://blog.fredrikhaglund.se/wp-content/uploads/2007/09/workaround.PNG" alt="Source code for workaround" /></a></p>
<p>Any feedback is appreciated.</p>
<p><a href="http://fredrikhaglund.se/blog/070927/Global.asax.zip">Download example code here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2007/09/27/the-mysterious-problem-with-webresourceaxd/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>
