'How add CORS to IIS web.config

I am trying to run my web site on IIS. it is a web map and i use another service from another server and i get CORS error: The 'Access-Control-Allow-Origin' header contains multiple values , but only one is allowed.** I have installed CORS addon on chrome and using it i can connect to this service. Now i try to configure IIS web.config file to connect this service without any other third party plugin or addon. So, i try to add this code to my web.config file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
    <httpProtocol>
     <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
     </customHeaders>
    </httpProtocol>
        <directoryBrowse enabled="true" />
        <defaultDocument>
            <files>
                <clear />
                <add value="index.php" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

but i get error: 500 - Internal server error.

What i do wrong i do not know.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source