This project is read-only.

CORS support within Web API?

Topics: Web Api
Dec 21, 2011 at 2:13 AM
Edited Dec 21, 2011 at 2:15 AM
Hi, good day everyone, im new in Web API and not sure is this the correct place to ask this question. How to enable CORS within Web API? im using preview 6. I found following code from
<?xml version="1.0" encoding="utf-8"?>
       <add name="Access-Control-Allow-Origin" value="*" />


Is that this simple? Is there any extra code needed in Web API itself?


Dec 21, 2011 at 11:00 AM

CORS is controlled entirely by HTTP header.  I'm not sure if its enough to add only that one? I've seen an example with these as well:
'Access-Control': 'allow <*>'
'Access-Control-Allow-Origin': '*'
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE'
'Access-Control-Allow-Headers': 'AUTHORIZATION, X-REQUESTED-WITH'
'Access-Control-Expose-Header': 'CONTENT-TYPE'
'Access-Control-Max-Age': '1728000'