In order to enable it, you need to make a modification to your web.config file. Enter the following somewhere between your system.webServer tags:
<httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Allow-Headers" value="Content-Type" /> <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" /> </customHeaders> </httpProtocol>Also, in your ApiController, add an empty Options method (some browsers issue this command to check the validity of a cross origin request):
public class DataController : ApiController { public void Options() { } }
No comments:
Post a Comment