2

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.

user1652792
  • 309
  • 3
  • 18

1 Answers1

0

Have you tried setting CORS policy via the portal?

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

viperguynaz
  • 12,044
  • 4
  • 30
  • 41
  • 1
    I have try add custom response header in azure web app, some specific header are not take effect in azure web app . I am depressed – Julian89757 Jun 08 '18 at 08:53