title: Configure IIS Express 8 to enable CORS
body: <p>I'm writing WCF services that will be used by clients out in the wild so they need to handle cross-origin requests. I have a problem with enabling my development server to accept such requests. Here is the scenario:</p>
  
  <ul>
  <li>I'm running the WCF project in an instance of Visual Studio 2012, using IIS Express 8 as the server on a specific port.</li>
  <li>I'm running the client project in another instance of Visual Studio 2012, also using IIS Express 8 as the server. This project uses AJAX to consume services in the other project.</li>
  </ul>
  
  <p>When I run the client project in IE there is no problem because IE does not send the preflight OPTIONS request. When I run it in Chrome however the preflight OPTIONS request returns a 405 Method Not Allowed and Chrome gives up on the service. Previous versions of Chrome would just ignore the error and continue with the actual POST request (or Get, whatever...) but later versions appear to be pickier.</p>
  
  <p>I've also run into this with a deployed WCF project and solved it by moving the OPTIONSVerbHandler to the top of the Handler Mappings list in IIS.</p>
  
  <p>I should point out that I'm using the most generous web.config settings I can think of to try to allow CORS. For instance I have this in the WCF project's configuration:</p>
  
  <pre><code>&lt;httpProtocol&gt;
    &lt;customHeaders&gt;
      &lt;remove name="X-Powered-By" /&gt;
      &lt;add name="Access-Control-Allow-Origin" value="*" /&gt;
      &lt;add name="Access-Control-Allow-Headers" value="*" /&gt;
      &lt;add name="Access-Control-Allow-Methods" value="*" /&gt;
      &lt;add name="X-Powered-By" value="*" /&gt;
    &lt;/customHeaders&gt;
  &lt;/httpProtocol&gt;
  </code></pre>
  
  <p>Regardless, any client cross-origin requests to the WCF project running from code fail with the 405 error.</p>
  
  <p>Any help setting up either the WCF project itself or IIS Express 8 to enable CORS?</p>
  
  <p>Thanks!</p>