We cannot call another doman with AJAX requests from our web page due to browser security. This type of restriction is called as same-origin policy, and prevents a malicious site from reading sentitive data from another site. However, sometimes you might want to let other sites call your web API.
For allow other sites to call your web api add following lines in your config file:-
<system.webServer>
<httpProtocol>
<customHeaders>
<!-- Adding the following custom HttpHeader will help prevent CORS from stopping the Request-->
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
No comments:
Post a Comment