title: PUT and Delete not working with ASP.NET WebAPI and Database on Windows Azure
body: <p>I'm working on a ASP.NET WebAPI project with basic CRUD operations. The project runs locally and has a sample database living inside Windows Azure. </p>
  
  <p>So far, the Http GET and POST works fine, giving me a 200 and 201. But I'm struggling with DELETE and POST. I changed the handlers in the Web.config, removed WebDav, but none of this worked. Also enabling CORS and all sorts of Attributes like [AcceptVerbs] didn't work. </p>
  
  <p>Any idea what I am doing wrong?</p>
  
  <p>Fiddler Raw Output:</p>
  
  <pre><code>HTTP/1.1 405 Method Not Allowed
  Cache-Control: no-cache
  Pragma: no-cache
  Allow: GET
  Content-Type: application/json; charset=utf-8
  Expires: -1
  Server: Microsoft-IIS/8.0
  X-AspNet-Version: 4.0.30319
  X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcTWFyY1xPbmVEcml2ZVxEb2t1bWVudGVcRmlcVnNQcm9qZWt0ZVxONTIwMTQwODI1XE41XE41XGFwaVxwcm9kdWN0XDEwODM=?=
  X-Powered-By: ASP.NET
  Date: Sun, 14 Sep 2014 15:00:43 GMT
  Content-Length: 75
  
  {"Message":"The requested resource does not support http method 'DELETE'."} 
  </code></pre>
  
  <p>Web.config:</p>
  
  <pre><code>&lt;system.webServer&gt;
      &lt;validation validateIntegratedModeConfiguration="false" /&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"&gt;
        &lt;remove name="WebDAVModule" /&gt;
      &lt;/modules&gt;
      &lt;handlers&gt;
        &lt;remove name="WebDAV" /&gt;
        &lt;remove name="ExtensionlessUrlHandler-Integrated-4.0" /&gt;
        &lt;add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" /&gt;
      &lt;/handlers&gt;
   &lt;/system.webServer&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code> public class ProductController : BaseApiController
      {
          public ProductController(IRepository&lt;Product&gt; repo)
              : base(repo)
          {
  
          }
  
          [HttpGet]
          public IEnumerable&lt;Product&gt; Get()
          {
              //...
          }
  
          [HttpGet]
          public Product Get(int id)
          {
              //...
          }
  
          [HttpPost]
          public HttpResponseMessage Post([FromBody] Product product)
          {
             //...
          }
  
          [HttpPut]
          public HttpResponseMessage Put(int productId, [FromBody] Product product)
          {
              //..
          }
  
          [HttpDelete]
          public HttpResponseMessage Delete(int productId)
          {
              //..
          }
  
      }
  </code></pre>
  
  <p>Routing &amp; Formatters:</p>
  
  <pre><code> public static void Register(HttpConfiguration config)
      {
          // Web API configuration and services
          // Configure Web API to use only bearer token authentication.
          config.SuppressDefaultHostAuthentication();
          config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
  
  
          config.Routes.MapHttpRoute(
              name: "Product",
              routeTemplate: "api/product/{id}",
              defaults: new {controller = "product",  id = RouteParameter.Optional }
          );
  
          // Custom Formatters:
          config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(
              config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t =&gt; t.MediaType == "application/xml"));
  
          var jsonFormatter = config.Formatters.OfType&lt;JsonMediaTypeFormatter&gt;().First();
          jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
      }
  }
  </code></pre>