Reputation: 21
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at API URL. This can be fixed by moving the resource to the same domain or enabling CORS.
I have installed Microsoft.AspNet.WebApi.Cors in API project, but still it's not working.
Also modified web.config for Access control but not successful.
Is there any way to call API from javascript?
Upvotes: 0
Views: 3450
Reputation: 287
You just need to add this code in web.config of Api.
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
Upvotes: 2