I have both my web and api projects deployed to separate Azure webapps and am struggling with a CORS issue. When deployed locally everything works fine, but not once published to Azure.

I am using two different methods to enable CORS and neither seem to be solving my issue.

Potential Fixes:

1. In my web.config I add a customHeader for `<add name="Access-Control-Allow-Origin" value="*" />`
2. In the Register method of WebApiConfig.cs I call enableCors as `var cors = new EnableCorsAttribute("*", "*", "*");` `config.EnableCors(cors);`

The scenarios, referencing the above two fixes, are as follows:

* With neither #1 or #2 used every server call returns a no access-control-allow-origin error (expected)
* With both #1 and #2 used I receive an error that I am enabling CORS twice with the same value (expected)
* If I only use #1 I don't receive a CORS error but every API method returns a 405 not allowed error
* If I only use #2 every api call returns a no access-control-allow-origin error

**Question:** How can I globally enable CORS for my .NET Web Api project hosted in Azure?

appstart and register code:

```
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        GlobalConfiguration.Configure(WebApiConfig.Register);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
    }

    public static void Register(HttpConfiguration config)
    {
        // Enable CORS
        // TODO, * below is debug only
        var cors = new EnableCorsAttribute("*", "*", "*");
        config.EnableCors(cors);

        // Web API configuration and services
        // Configure Web API to use only bearer token authentication.
        config.SuppressDefaultHostAuthentication();
        config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

        // Web API routes
        config.MapHttpAttributeRoutes();

        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );
    }

```