title: Could not get POST to work on Azure Website
body: <p>I have an asp.net web application with REST Webservices which works fine on local, but when I upload it to Azure it does not work anymore... I'm doing a POSTasync, but I could see in my logfiles that GET is executed.</p>
  
  <p>I've updated my web.config as proposed <a href="https://stackoverflow.com/a/25171133/672756">here</a> and <a href="https://forums.asp.net/t/1891310.aspx?HTTP+405+Method+Not+Allowed" rel="nofollow noreferrer">here</a> but it did not change anything.</p>
  
  <p>Here is my MessageController:</p>
  
  <pre><code>Imports System.Net
  Imports System.Net.Http
  Imports System.Web.Http
  Imports Microsoft.Practices.EnterpriseLibrary.Logging
  
  Public Class Test
      Public Subject As String
      Public Body As String
  End Class
  
  Public Class MessagesController
      Inherits ApiController
  
      ' GET api/&lt;controller&gt;
      Public Function GetAllValues() As DataTable
      ...
      End Function
  ' POST api/&lt;controller&gt;
  Public Function PostValue(&lt;FromBody()&gt; ByVal value As Test) As HttpResponseMessage
  ...
  End Function
  </code></pre>
  
  <p>I've also tried changed the Function PostValue to Sub PostValue without success.</p>
  
  <p>My Global.asax looks like this:</p>
  
  <pre><code>Imports System.Web.SessionState
  Imports System.Web.Http
  
  Public Class Global_asax
      Inherits System.Web.HttpApplication
  
      Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
          Web.Routing.RouteTable.Routes.MapHttpRoute(name:="DefaultApi", routeTemplate:="api/{controller}/{id}", defaults:=New With {
          Key .id = System.Web.Http.RouteParameter.[Optional]})
  End Sub
  </code></pre>
  
  <p>If the GetAllValues exists, PostAsync calls the GetAllValues for whatever reason. If I delete the GetAllValues for testing, I get "Method not allowed".</p>
  
  <p>Here is the method I use on my test aspx page to call the REST Webservice:</p>
  
  <pre><code>Private Async Sub PostTest_Click(sender As Object, e As EventArgs) Handles PostTest.Click
      Dim m As New Test
      m.Subject = "Test"
      m.Body = "Testbody"
  
      Dim client As New Http.HttpClient
  
      Dim JsonData As String = JsonConvert.SerializeObject(m)
      Dim theContent As New Http.StringContent(JsonData, Encoding.UTF8, "application/json")
      Dim aResponse As Http.HttpResponseMessage = Await client.PostAsync("https://example.com/api/messages/", theContent)
  </code></pre>
  
  <p><strong>Update</strong>
  When I remove the GET method from my controller I get error message "MethodNotAllowed". Having a closer look at the returned content confuses me even more. The content is:</p>
  
  <pre><code>{"Message":"The requested resource does not support http method 'GET'."}
  </code></pre>
  
  <p>But I'm using Await client.<strong>Post</strong>Async ....?</p>
  
  <p><strong>Update 2</strong>
  I've also tried PostAsJsonAsync, but error is still that <strong>'GET'</strong> is not supported....</p>
  
  <p><strong>Update 3</strong>
  I've now used <a href="http://www.telerik.com/fiddler" rel="nofollow noreferrer" title="Fiddler">Fiddler</a> and it seems that the POST itself works fine... With Fiddler Composer I could send POST to my azure https URL and the POST process is triggered as expected... Now I don't know why both client.PostAsync and client.PostAsJsonAsync seem to send a GET to the azure live url while the same code sends a POST on my localhost.... :-(</p>