title: Getting 405 error when making a DELETE request from an asp.net core app
body: <p>I have an asp.net core API, from which I am trying to make a DELETE request to another asp.net core API. When I call the first API I receive a 405 error when it makes the delete call to the second API. I've tried the solution found here; <a href="https://stackoverflow.com/questions/48188895/asp-net-core-with-iis-http-verb-not-allowed">ASP.NET Core with IIS - HTTP Verb Not Allowed</a>, and several other related solutions without success. I've also tried <a href="https://docs.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-2.2" rel="nofollow noreferrer">Enabling Cross-Origin Requests (CORS)</a> in my Startup.cs file, however nothing seemed to change.</p>
  
  <p>Here is my delete endpoint:</p>
  
  <pre><code>    [HttpDelete("MyDeleteEndpoint")]
      public async Task MyDeleteEndpoint([FromRoute] string id)
      {
          var http = new HttpClient();
  
          var response = await http.DeleteAsync("https://myserver:443/api/mycontroller/{id});
  
          //do more stuff
      }    
  </code></pre>
  
  <p>Here is my web.config:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="false"&gt;
        &lt;remove name="WebDAVModule" /&gt;
      &lt;/modules&gt;
    &lt;/system.webServer&gt;
  &lt;/configuration&gt;  
  </code></pre>
  
  <p>Here is my ConfigureServices and my Configure methods in Startup.cs:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
    services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
  
    services.AddCors(options =&gt;
    {
        options.AddPolicy("mypolicy",
        builder =&gt;
        {
            builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
        });
    });
  }
  
  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
      if (env.IsDevelopment())
      {
          app.UseDeveloperExceptionPage();
      }
      else
      {
      // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
           app.UseHsts();
      }
  
      app.UseCors("mypolicy");
      app.UseHttpsRedirection();
      app.UseMvc();
  }
  </code></pre>
  
  <p>Any ideas on what I could be doing wrong?</p>