Celebrate Our 22nd Anniversary with Huge Savings! Up to 70% Off

How to setup Access-Control-Allow-Origin for IIS 8 in web config?

Please follow the below steps to enable Access-Control-Allow-Origin in IIS 8 for web API calls.

1. Open Internet Information Service (IIS) Manager.

iis-select
2. Select the website you require and click on HTTP Response Headers.

http-response-headers

3. Click on Add button on the Actions pane.

4. Enter the below details in Custom HTTP Response Headers.

  • Enter Access-Control-Allow-Origin as the header name.

  • Enter * as the header value.

Custom http-response-headers

5. Hit the OK button.

6. Now, you will have to add the following code to your web.config file.

<?xml version="1.0" encoding="utf-8"?>

<configuration>

 <system.webServer>

   <httpProtocol>

     <customHeaders>

       <add name="Access-Control-Allow-Origin" value="*" />

     </customHeaders>

   </httpProtocol>

 </system.webServer>

</configuration>



Was this answer helpful?

« Back