title: IIS7.5 Gives 500 Internal Server Error when trying to use DELETE verb
body: <p>I am trying to issue a <code>DELETE</code> to an IIS7.5 resource:</p>
  
  <pre><code>DELETE http://198.252.206.16:48251/Test/foo.ashx HTTP/1.1
  Accept: */*
  Accept-Language: en-us
  Accept-Encoding: gzip, deflate
  User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
  Host: 198.252.206.16:48251
  Content-Length: 0
  Connection: Keep-Alive
  Pragma: no-cache
  </code></pre>
  
  <p>And the server responds with:</p>
  
  <pre><code>HTTP/1.1 500 Internal Server Error
  Server: Microsoft-IIS/7.5
  X-Powered-By: ASP.NET
  Date: Wed, 12 Feb 2014 01:01:30 GMT
  Content-Length: 0
  </code></pre>
  
  <p>The damnedest thing is:</p>
  
  <ul>
  <li>it works fine inside Cassini (the .NET based web-server used by Visual Studio)</li>
  <li>nothing is logged in the Windows Event log</li>
  <li>Custom errors are off in the site's <code>web.config</code></li>
  <li>No verbs are being filtered (or all verbs are being included)</li>
  <li>WebDAV module is disabled</li>
  <li>LiveStreamingHandler module is not installed</li>
  </ul>
  
  <p>Why does IIS not work?</p>
  
  <h1>Steps to reproduce</h1>
  
  <p>Create a web-site with the generic handler:</p>
  
  <p><strong>Foo.ashx</strong></p>
  
  <pre><code>&lt;%@ WebHandler Language="C#" Class="Foo" %&gt;
  
  using System;
  using System.Web;
  
  public class Foo : IHttpHandler
  {
      public void ProcessRequest(HttpContext context)
      {
      }
  
      public bool IsReusable { get { return false; } }
  }
  </code></pre>
  
  <p>and then issue a <code>DELETE</code> verb to the resource. You can use Fiddler to compose the request, if you like:</p>
  
  <p><img src="https://i.stack.imgur.com/G1dg7.png" alt="enter image description here"></p>
  
  <h1>What about other verbs you ask?</h1>
  
  <p>You didn't try to reproduce it, did you? Well, i'll show you the results here:</p>
  
  <ul>
  <li><strong><code>GET</code></strong>: <em>works</em></li>
  <li><strong><code>POST</code></strong>: <em>works</em></li>
  <li><strong><code>PUT</code></strong>: <em>works</em></li>
  <li><strong><code>HEAD</code></strong>: <em>works</em></li>
  <li><strong><code>TRACE</code></strong>: <code>501 Not Implemented</code></li>
  <li><strong><code>DELETE</code></strong>: <code>500 Internal Server Error</code></li>
  <li><strong><code>SEARCH</code></strong>: <code>405 Method Not Allowed</code></li>
  <li><strong><code>PROPFIND</code></strong>: <code>500 Internal Server Error</code></li>
  <li><strong><code>PROPPATCH</code></strong>: <code>500 Internal Server Error</code></li>
  <li><strong><code>PATCH</code></strong>: <code>405 Method Not Allowed</code></li>
  <li><strong><code>MKCOL</code></strong>: <code>405 Method Not Allowed</code></li>
  <li><strong><code>COPY</code></strong>: <code>500 Internal Server Error</code></li>
  <li><strong><code>MOVE</code></strong>: <code>500 Internal Server Error</code></li>
  <li><strong><code>LOCK</code></strong>: <code>500 Internal Server Error</code></li>
  <li><strong><code>UNLOCK</code></strong>: <code>500 Internal Server Error</code></li>
  <li><strong><code>OPTIONS</code></strong>: <code>200 OK</code></li>
  <li><strong><code>IISUCKSFOO</code></strong> <code>405 Method Not Allowed</code></li>
  </ul>
  
  <p>And just to be anal retentive, a snippet of the relevant portions from <code>web.config</code>:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
      &lt;system.web&gt;
          &lt;httpRuntime/&gt;
          &lt;!-- IISFIX: By default IIS hides errors--&gt;
          &lt;customErrors mode="Off"/&gt;
          &lt;!-- IISFIX: By default IIS ignores the browser's culture --&gt;
          &lt;globalization culture="auto" uiCulture="auto"/&gt;
          &lt;!--Doesn't work for ASP.net web-sites, only ASP.net applications--&gt;
          &lt;trace enabled="true" requestLimit="40" localOnly="false" /&gt;
  
          &lt;compilation debug="true" targetFramework="4.0"&gt;
              &lt;assemblies&gt;
                  &lt;add assembly="System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/&gt;
                  &lt;add assembly="System.DirectoryServices.AccountManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;
                  &lt;add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;
              &lt;/assemblies&gt;
          &lt;/compilation&gt;
      &lt;/system.web&gt;
  
      &lt;!-- ASP.net web-sites do not support WebPageTraceListener (only ASP.net web-applications) 
    So this section doesn't work; and does nothing. 
    But if Microsoft ever fixes IIS, we will start working automagically. --&gt;
      &lt;system.diagnostics&gt;
          &lt;trace&gt;
              &lt;listeners&gt;
                  &lt;add name="WebPageTraceListener" type="System.Web.WebPageTraceListener, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/&gt;
              &lt;/listeners&gt;
          &lt;/trace&gt;
      &lt;/system.diagnostics&gt;
  
      &lt;system.webServer&gt;
          &lt;!-- IISFIX: By default IIS ignores custom error pages --&gt;
          &lt;httpErrors existingResponse="PassThrough"/&gt;
          &lt;defaultDocument&gt;
              &lt;files&gt;
                  &lt;clear/&gt;
                  &lt;add value="Default.htm"/&gt;
                  &lt;add value="Default.asp"/&gt;
                  &lt;add value="index.htm"/&gt;
                  &lt;add value="index.html"/&gt;
                  &lt;add value="iisstart.htm"/&gt;
                  &lt;add value="default.aspx"/&gt;
                  &lt;add value="test.htm"/&gt;
              &lt;/files&gt;
          &lt;/defaultDocument&gt;
  
          &lt;!--IISFIX: By default IIS doesn't understand HTTP protocol--&gt;
          &lt;security&gt;
              &lt;requestFiltering&gt;
                  &lt;verbs&gt;
                      &lt;add verb="OPTIONS" allowed="true" /&gt;
                      &lt;add verb="GET" allowed="true" /&gt;
                      &lt;add verb="HEAD" allowed="true" /&gt;
                      &lt;add verb="POST" allowed="true" /&gt;
                      &lt;add verb="PUT" allowed="true" /&gt;
                      &lt;add verb="TRACE" allowed="true" /&gt;
                      &lt;add verb="DELETE" allowed="true" /&gt;
                  &lt;/verbs&gt;
              &lt;/requestFiltering&gt;
          &lt;/security&gt;
  
          &lt;modules runAllManagedModulesForAllRequests="true"&gt;
              &lt;!--IISFIX: Whatever this is, it causes 405 Method Not Allowed errors on IIS when using PUT. (Microsoft's broken by defult)--&gt;
              &lt;remove name="WebDAVModule"/&gt;
          &lt;/modules&gt;
  
      &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>Edit</strong> - forgot the screenshot of verbs:</p>
  
  <p><img src="https://i.stack.imgur.com/6Zglp.png" alt="enter image description here"></p>
  
  <p>The question was sufficiently asked in the title. The rest of the post is just filler to make it look like it shows research effort; which means you have to upvote it - the tooltip on the upvote arrow says so!</p>