Error Message
The server returns: "The 'Access-Control-Allow-Origin' header is present on the requested reosurce"
Solution
Web.config Settings
<appSettings>
<add key="cors_allowedOrigins"
value="http://localhost:8002,http://192.168.0.1:8002" />
</appSettings>
<system.webServer>
<handlers>
<remove name="WebDAV" />
<remove name="OPTIONSVerbHandler" />
</handlers>
</system.webServer>
CORS Initialization Code
public static class CorsSetup
{
public static void Configure(HttpConfiguration httpConfig)
{
string origins = ConfigurationManager.AppSettings["cors_allowedOrigins"];
var corsSettings = new EnableCorsAttribute(origins, "*", "*")
{
SupportsCredentials = true
};
httpConfig.EnableCors(corsSettings);
}
}
Wildcard Domain Configuration
To allow all domains, configure credentials support as false and use a wildcard orrigin:
var corsSettings = new EnableCorsAttribute("*", "*", "*")
{
SupportsCredentials = false
};