title: XMLHttpRequest can not load. Response for preflight has invalid HTTP status code 405
body: <p>I have read many similar problems in StackOverflow, but the solutions don't work for me.
  I can use it using Postman (Chrome extension). I am passing data as 'Header'. And I get 200 return code.</p>
  
  <p><a href="https://i.stack.imgur.com/GZZgH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GZZgH.png" alt="enter image description here"></a></p>
  
  <p>I need to call this method using ajax Jquery :</p>
  
  <pre><code>$.ajax(apiUri, {
     beforeSend: function (xhr, settings) {
         xhr.setRequestHeader('Authorization', 'Bearer ' + $('#AccessToken').val());
     },
     dataType: 'text',
     cache: false,
     success: function (data) {
         console.log(data);
         $('#output').text(data);
     }
  });
  </code></pre>
  
  <p>But in this case, I got an error.</p>
  
  <p>Like <a href="https://i.stack.imgur.com/VmgyZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VmgyZ.png" alt="console error using jquery/Ajax"></a></p>
  
  <p>At Resource server side I have set in web.config.</p>
  
  <pre><code>&lt;httpProtocol&gt;
    &lt;customHeaders&gt;
      &lt;add name="Access-Control-Allow-Origin" value="*" /&gt;
      &lt;add name="Access-Control-Allow-Headers" value="Content-Type" /&gt;
      &lt;add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" /&gt;
    &lt;/customHeaders&gt;
  &lt;/httpProtocol&gt;
  </code></pre>