Angular -> Web Api 2: "No 'Access-Control-Allow-Origin' header" Angular -> Web Api 2: "No 'Access-Control-Allow-Origin' header" angularjs angularjs

Angular -> Web Api 2: "No 'Access-Control-Allow-Origin' header"


To fix this issue, you need to configure CORS-es. First go to "Web.config", find "system.webServer" tag, inside of it add next lines:

<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>

That is all.


For .NET server can configure this in web.config as shown below

 <system.webServer>   <httpProtocol>     <customHeaders>       <add name="Access-Control-Allow-Origin" value="your_clientWebUrl" />     </customHeaders>   </httpProtocol> </system.webServer>


I also work with webapi2 and AngluarJS client (different server) in Azure WebSites.

please check my answer: https://stackoverflow.com/a/25758949/361100

If you cannot solve the problem, check other answers of the above link.