0

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?

user3224493
  • 11
  • 1
  • 5

1 Answers1

2

You just need to add this code in web.config of Api.

<httpProtocol>
  <customHeaders>
    <add name="Access-Control-Allow-Origin" value="*" />
  </customHeaders>
 </httpProtocol>
Hayat Sama
  • 287
  • 2
  • 10