jmro
jmro

Reputation: 419

Azure websites doesnt allow to send custom headers?

Why azure websites ignores my web application custom headers? Ive tried to send headers via 3 methods:

Ive tried to install Cors nuget package:

    public static void Register(HttpConfiguration config)
    {
        config.EnableCors(new EnableCorsAttribute("*", "*", "*");
    }

Also tried to setup custom headers in web.config

<system.webServer>
 <httpProtocol>
   <customHeaders>
     <add name="Access-Control-Allow-Origin" value="*" />
   </customHeaders>
 </httpProtocol>
</system.webServer>

Finally i tried to create filter:

public class CorsFilter : ActionFilterAttribute
{
    public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
    {
        actionExecutedContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
    }
}

All of three above methods worked fine on my local dev environment. But when i publish my app to azurewebistes it ignores my custom headers. Is there any reason for that ?

I have dreamspark subscription.

Upvotes: 2

Views: 460

Answers (1)

viperguynaz
viperguynaz

Reputation: 12174

Have you tried setting CORS policy via the portal?

https://portal.azure.com >> YourAppService >> Settings >> CORS

Upvotes: 0

Related Questions