title: Enable CORS for Web API 1, .net 4.0
body: <p>I need to enable CORS for my Web API and I can't upgrade to Framework 4.5 at the moment. (I know about System.Web.Http.Cors.EnableCorsAttribute.)</p>
  
  <p>I've tried to add the following to my Web.config to see if it worked, but it didn't:</p>
  
  <pre><code>&lt;system.webServer&gt;
  &lt;httpProtocol&gt;
    &lt;customHeaders&gt;
      &lt;add name="Access-Control-Allow-Origin" value="*"/&gt;
    &lt;/customHeaders&gt;
  &lt;/httpProtocol&gt;
  </code></pre>
  
  <p>I've also tried to set the Access-Control-Allow-Origin header to "*" manually by use of System.Web.Http.Filters.ActionFilterAttribute (based on this post: <a href="https://stackoverflow.com/questions/20349447/add-custom-header-to-all-responses-in-web-api">Add custom header to all responses in Web API</a>) - but that didn't work out either as the request is rejected before it gets to the action filtering.</p>
  
  <p>So I'm kinda stuck now.. Any help is appreciated.</p>
  
  <p>Edit: Turns out</p>
  
  <pre><code>&lt;add name="Access-Control-Allow-Origin" value="*"/&gt;
  </code></pre>
  
  <p>was the answer all along, I must've done something wrong previously when I tested it. But this solution means that all actions are CORS enabled (which will do for now).</p>