title: HttpClient POST to WEB API method returns 405 (Method not allowed)
body: <p>Following request works perfectly when using Postman (Browser) within IIS Express and VS 2015 in a Debug Session:</p>
  
  <pre><code>POST http://localhost:51072/api/cs/processor/process
  
  {
  'code':'TEST',
    'mode':0
  }
  </code></pre>
  
  <p>This is my web api controller method </p>
  
  <pre><code>[RoutePrefix("api/cs")]
  public class ProcessorController : UmbracoApiController
  {...
  
  [AllowAnonymous]
  [Route("processor/process")]
  [HttpPost()]
  public IHttpActionResult Process([FromBody] ProcessSurvey dto)
  {
      if (!HttpContext.Current.Request.IsLocal)
      {
          return Content(HttpStatusCode.Forbidden, "Not allowed to start survey from remote host.");
      }
      ProcessSurveyResponse resp = new ProcessSurveyResponse();
      switch (dto.Code)
      {
          case "ITS":
              resp = Execute(dto.Mode);
              break;
          default:
              resp.Message = "Test successful!";
              break;
      }
      return Content(HttpStatusCode.Created, resp);
  }
  </code></pre>
  
  <p>Although when I try to access this method with the exact same request data it returns a 405. After digging deeper I've found that internally it's done a redirect (302). But cannot find any information about what's going on and why in the IIS logs.</p>
  
  <p>What I've done so far is WebDAV removed, Attribute is Http not Mvc, all constellations of route config (belkow is my current one)</p>
  
  <pre><code>    public static void Register(HttpConfiguration config)
      {
          // Attribute routing.
          config.MapHttpAttributeRoutes();
  
  
      config.Routes.MapHttpRoute(
          name: "DefaultApiFull",
          routeTemplate: "api/{controller}/{action}/{id}",
          defaults: new { id = RouteParameter.Optional });
  
      config.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/{controller}/{id}",
              defaults: new { id = RouteParameter.Optional }
          );
      }
  </code></pre>
  
  <p>and this is my init method</p>
  
  <pre><code>    GlobalConfiguration.Configure(WebApiConfig.Register); //WebApi 2 Register method
  </code></pre>
  
  <p>Really do not know what to do ... struggling for 2 days now and I have no idea where to look further.</p>
  
  <p>Here is the HttpClient call</p>
  
  <pre><code>using (var client = new HttpClient())
              {
                  client.DefaultRequestHeaders.Clear();
                  client.DefaultRequestHeaders.ExpectContinue = false;
                  client.DefaultRequestHeaders.Accept.Clear();
                  client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("*/*"));
                  var json = JsonConvert.SerializeObject(dto);
                  StringContent content = new StringContent(json, Encoding.UTF8, "application/json");
                  log.Debug("Call " + baseUrl);
                  HttpResponseMessage response = await client.PostAsync("http://localhost:51072/api/cs/surveyprocessor/process/", content);
                  string data = await response.Content.ReadAsStringAsync();
                  if (response.IsSuccessStatusCode)
                  {
                      result = JsonConvert.DeserializeObject&lt;ProcessSurveyResponse&gt;(data);
                  }
                  else
                  {
                      result.Message = data;
                  }
                  return result;
              }
  </code></pre>
  
  <p>And here is my DTO</p>
  
  <pre><code>public class ProcessSurvey
  {
      [JsonProperty(PropertyName = "mode")]
      public int Mode { get; set; }
      [JsonProperty(PropertyName = "code")]
      public string Code { get; set; }
      [JsonProperty(PropertyName = "customers")]
      public IList&lt;int&gt; Customers { get; set; }
  }
  </code></pre>
  
  <p>What's interesting that when I POST over the HttpClient it seems that it does not reach the WebApi module ... </p>
  
  <blockquote>
  <pre><code>&gt; iisexpress.exe Information: 0 : Request, Method=GET,
  &gt; Url=http://localhost:51072/api/cs/surveyprocessor/process/?AspxAutoDetectCookieSupport=1,
  &gt; Message='http://localhost:51072/api/cs/surveyprocessor/process/?AspxAutoDetectCookieSupport=1'
  &gt; iisexpress.exe Information: 0 : Message='SurveyProcessor',
  &gt; Operation=NamespaceHttpControllerSelector.SelectController
  &gt; iisexpress.exe Information: 0 :
  &gt; Message='SSI.CSS.Serviceportal.CS.Controller.SurveyProcessorController',
  &gt; Operation=DefaultHttpControllerActivator.Create iisexpress.exe
  &gt; Information: 0 :
  &gt; Message='SSI.CSS.Serviceportal.CS.Controller.SurveyProcessorController',
  &gt; Operation=HttpControllerDescriptor.CreateController iisexpress.exe
  &gt; Information: 0 : Message='Will use same 'JsonMediaTypeFormatter'
  &gt; formatter',
  &gt; Operation=JsonMediaTypeFormatter.GetPerRequestFormatterInstance
  &gt; iisexpress.exe Information: 0 : Message='Selected
  &gt; formatter='JsonMediaTypeFormatter', content-type='application/json;
  &gt; charset=utf-8'', Operation=DefaultContentNegotiator.Negotiate
  &gt; iisexpress.exe Warning: 0 : Message='UserMessage='The requested
  &gt; resource does not support http method 'GET'.'',
  &gt; Operation=ApiControllerActionSelector.SelectAction, Status=405
  &gt; (MethodNotAllowed), Exception=System.Web.Http.HttpResponseException:
  &gt; Processing of the HTTP request resulted in an exception. Please see
  &gt; the HTTP response returned by the 'Response' property of this
  &gt; exception for details.    bei
  &gt; System.Web.Http.Controllers.ApiControllerActionSelector.ActionSelectorCacheItem.SelectAction(HttpControllerContext
  &gt; controllerContext)    bei
  &gt; System.Web.Http.Controllers.ApiControllerActionSelector.SelectAction(HttpControllerContext
  &gt; controllerContext)    bei
  &gt; System.Web.Http.Tracing.Tracers.HttpActionSelectorTracer.&lt;&gt;c__DisplayClass2.&lt;System.Web.Http.Controllers.IHttpActionSelector.SelectAction&gt;b__0()    bei
  &gt; System.Web.Http.Tracing.ITraceWriterExtensions.TraceBeginEnd(ITraceWriter
  &gt; traceWriter, HttpRequestMessage request, String category, TraceLevel
  &gt; level, String operatorName, String operationName, Action`1 beginTrace,
  &gt; Action execute, Action`1 endTrace, Action`1 errorTrace) iisexpress.exe
  &gt; Warning: 0 : Message='UserMessage='The requested resource does not
  &gt; support http method 'GET'.'',
  &gt; Operation=SurveyProcessorController.ExecuteAsync, Status=405
  &gt; (MethodNotAllowed), Exception=System.Web.Http.HttpResponseException:
  &gt; Processing of the HTTP request resulted in an exception. Please see
  &gt; the HTTP response returned by the 'Response' property of this
  &gt; exception for details.    bei
  &gt; System.Web.Http.Controllers.ApiControllerActionSelector.ActionSelectorCacheItem.SelectAction(HttpControllerContext
  &gt; controllerContext)    bei
  &gt; System.Web.Http.Controllers.ApiControllerActionSelector.SelectAction(HttpControllerContext
  &gt; controllerContext)    bei
  &gt; System.Web.Http.Tracing.Tracers.HttpActionSelectorTracer.&lt;&gt;c__DisplayClass2.&lt;System.Web.Http.Controllers.IHttpActionSelector.SelectAction&gt;b__0()    bei
  &gt; System.Web.Http.Tracing.ITraceWriterExtensions.TraceBeginEnd(ITraceWriter
  &gt; traceWriter, HttpRequestMessage request, String category, TraceLevel
  &gt; level, String operatorName, String operationName, Action`1 beginTrace,
  &gt; Action execute, Action`1 endTrace, Action`1 errorTrace)    bei
  &gt; System.Web.Http.Tracing.Tracers.HttpActionSelectorTracer.System.Web.Http.Controllers.IHttpActionSelector.SelectAction(HttpControllerContext
  &gt; controllerContext)    bei
  &gt; System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext
  &gt; controllerContext, CancellationToken cancellationToken)    bei
  &gt; System.Web.Http.Tracing.Tracers.HttpControllerTracer.&lt;ExecuteAsyncCore&gt;d__5.MoveNext()
  &gt; --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---    bei
  &gt; System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
  &gt; task)    bei
  &gt; System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  &gt; task)    bei
  &gt; System.Web.Http.Tracing.ITraceWriterExtensions.&lt;TraceBeginEndAsyncCore&gt;d__18`1.MoveNext()
  &gt; iisexpress.exe Information: 0 : Response, Status=405
  &gt; (MethodNotAllowed), Method=GET,
  &gt; Url=http://localhost:51072/api/cs/surveyprocessor/process/?AspxAutoDetectCookieSupport=1,
  &gt; Message='Content-type='application/json; charset=utf-8',
  &gt; content-length=unknown' iisexpress.exe Information: 0 :
  &gt; Operation=JsonMediaTypeFormatter.WriteToStreamAsync iisexpress.exe
  &gt; Information: 0 : Operation=SurveyProcessorController.Dispose
  &gt; 'iisexpress.exe' (CLR v4.0.30319:
  &gt; /LM/W3SVC/2/ROOT-1-131394088034503203): Loaded
  &gt; 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET
  &gt; Files\root\4650863f\f01d951b\App_Web_ping.aspx.5f2dec3.f9ui73ad.dll'. 
  &gt; The thread 0x2830 has exited with code 0 (0x0). The thread 0x3f10 has
  &gt; exited with code 0 (0x0). The thread 0x2104 has exited with code 0
  &gt; (0x0).
  </code></pre>
  </blockquote>