sarpay
11/11/2014 - 10:13 AM

[.net] Allow CORS on IIS to access API from remote machine

[.net] Allow CORS on IIS to access API from remote machine

<system.webServer>
  <httpProtocol>
    <!--allows for cross domain request and access to webservice response-->
    <customHeaders>
      <clear/>
      <add name="Access-Control-Allow-Origin" value="*" />
      <add name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS, HEAD" />
      <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
      <add name="Access-Control-Max-Age" value="1728000" />
      <!--the value in seconds for how long the response to the preflight request can be cached for without 
    sending another preflight request.  In this case, 1728000 seconds is 20 days.-->
    </customHeaders>
  </httpProtocol>
</system.webServer>