title: How to enable Cors for a single Web Api method on self hosted OWIN
body: <p>I need to open single Web Api method to be called from another website (AngularJS) and I can't make it work. </p>
  
  <p>I added references to <code>Microsoft.Owin.Cors</code> and <code>System.Web.Http.Cors</code></p>
  
  <p>Added this line to <code>Configuration</code> method of my OWIN Startup class:</p>
  
  <pre><code>app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
  </code></pre>
  
  <p>Added <code>config.EnableCors();</code> to <code>ConfigureWebApi</code> method </p>
  
  <p>Added </p>
  
  <pre><code>[EnableCors(origins: "*", headers: "*", methods: "*")]
  </code></pre>
  
  <p>above my Web Api controller method. </p>
  
  <p>I still get </p>
  
  <pre><code>XMLHttpRequest cannot load {myUrl}. Response to preflight request doesn't
  pass access control check: No 'Access-Control-Allow-Origin' header is present 
  on the requested resource. Origin 'http://localhost' is therefore not 
  allowed access. The response had HTTP status code 401.
  </code></pre>
  
  <p>I tried differenct combinations of the above with no luck. I also saw other replies with adding code to <code>web.config</code> and <code>Global.asax</code>, but I'm on self hosted OWIN and don't have any of those. </p>
  
  <p>How can I make it work? </p>