Featured

    Featured Posts

Handle no 'Access-Control-Allow-Origin' - issues on client side in ASP.NET WebAPI

Since your .NET Web API and Client-Side projects are being hosted on different ports, it's considered a Cross-Domain (CORS) request.

Just add the proper header in your web.config from your web API application:

<configuration>
  <system.webServer>
    <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>
  </system.webServer>
</configuration>

author

Anand Jee

My Name is Anand Jee. I'm a software developer by profession as well as I'm a reader, gadget enthusiast, guitarist and traveller. I blog about code, technology, the web, gadgets, technology and cultures. I'm excited about new technology.

Get Free Email Updates to your Inbox!

Post a Comment

www.CodeNirvana.in

Copyright © Kodexpression