Why HTTP HEAD Request is not caught by routes.MapRoutes() while HTTP GET is?
<p>I have a .NET controller that handles image requests.</p>

<p>There is a URL rewriting rule in the web.config that converts <code>http://localhost/images/1809x1280/image1.jpg</code>
to <code>http://localhost/image/get/image1.jpg/1809/1280</code></p>

<p>I then have the following <code>RouteConfig</code> rule</p>

<pre><code>    routes.MapRoute()
        name: "Images",
        url: "image/get/{filename}/{width}/{height}",
        defaults: new { controller = "Image", action = "Get" }
    );
</code></pre>

<p>When I perform a <code>HTTP GET</code> request, the action is correctly routed to the correct control and I get the expected <code>HTTP/1.1 200 OK</code> response, however as I change the HTTP verb from <code>GET</code> to <code>HEAD</code> I receive a <code>HTTP/1.1 404 Not Found</code> response.</p>

<p>Having placed a breakpoint into my <code>ImageController.Get()</code> method I noticed that only the <code>HTTP GET</code> request was hitting it.</p>

<p>Having then placed a breakpoint inside <code>Application_BeginRequest</code> of <code>Global.asax.cs</code>, the breakpoint is hit for both <code>HTTP GET</code> and <code>HTTP HEAD</code> requests.</p>

<p>When the request was <code>HTTP HEAD</code> I had the following properties of the <code>Request</code> object:</p>

<p><code>RawUrl "/images/1809x1280/image1.jpg"  string</code></p>

<p><code>Url    {http://localhost/image/get/image1.jpg/1809/1280}   System.Uri</code></p>

<p>which are correct and indicate that the <code>web.config</code> rewriting rule has kicked in, however the <code>ImageController.Get()</code> is never hit.</p>

<p>It seems to be a problem with the <code>routes.MapRoute()</code> at this point but I'm not sure how to go about and investigate it.</p>