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.



  2. Select the website you required and click on HTTP Response Headers.



  3. Click on Add button at 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.

       

  1. Hit OK Button.

  2. Now you will have to add the following code in 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>

  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How To Create a Separate Application Pool And Assign It To a Website From The IIS?

This video tutorial will help you to create a separate application pool and assign to a website...