title: How to handle Http Error 405 Method Not Allowed?
body: <p>I am trying to access REST service hosted on console application from ajax GET/POST. As there will be different ports used in two applications , I have  configured REST service to handle cross origin requests. I have tried every available solution , still I am unable to access the service from ajax and getting 405.</p>
  
  <p>I am sharing Raw request-response stream captured by http analyser.</p>
  
  <pre><code>OPTIONS /Service/Contacts?_145***************** HTTP/1.1
  Accept: */*
  Origin: http:localhost:1053
  Access-Control-Request-Method: GET
  Access-Control-Request-Headers: access-control-allow-origin, access-control-allow-methods
  Accept-Encoding: gzip, deflate
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
  Host: bhawesh-pc:8000
  DNT: 1
  Connection: Keep-Alive
  Cache-Control: no-cache
  Content-Length: 0
  </code></pre>
  
  
  
  <pre><code>HTTP/1.1 405 Method Not Allowed
  Allow: POST, GET
  Content-Type: text/html; charset=UTF-8
  Server: Microsoft-HTTPAPI/2.0
  Access-Control-Allow-Origin: *
  Access-Control-Request-Method: POST,GET,PUT,DELETE,OPTIONS
  Access-Control-Allow-Headers: X-Requested-With,Content-Type
  Date: Tue, 05 Jan 2016 17:57:44 GMT
  Content-Length: 1565
  
  ï»¿&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;head&gt;
      &lt;title&gt;Service&lt;/title&gt;
      &lt;style&gt;BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } .heading1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}&lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div id="content"&gt;
        &lt;p class="heading1"&gt;Service&lt;/p&gt;
        &lt;p&gt;Method not allowed.&lt;/p&gt;
      &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>REST service configuration are based on <a href="http://enable-cors.org/server_wcf.html" rel="nofollow">http://enable-cors.org/server_wcf.html</a> and <a href="http://www.khalidabuhakmeh.com/rest-http-verbs-and-iis-express" rel="nofollow">http://www.khalidabuhakmeh.com/rest-http-verbs-and-iis-express</a></p>