Access-Control-Allow-Origin Header and the ASP.NET Web API

Access-Control-Allow-Origin Header and the ASP.NET Web API

Adding Header Information in Web.config

<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" />
        <add name="Access-Control-Allow-Credentials" value="true" />
       </customHeaders>
     </httpProtocol>
 </system.webServer>

As you can see we have added keys with value for the listed items.

 

  • Access-Control-Allow-Origin (For Origin)
  • Access-Control-Allow-Headers (For Headers)
  • Access-Control-Allow-Methods (For Methods)

source : https://dzone.com/articles/access-control-allow-origin-header-and-the-aspnet

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.