javascriptc#angularjshttp-status-code-504

AngularJS C# webapi works locally and after deploy gives No Access-Control-Allow-Origin


Folks, I am an having this issue below, when I tested locally both angularjs and C# webapi, worked perfectly, after the deploy on the server, it doesn't work anymore.

The Interest point is I do have another page, which points to the same server, basically, I made a copy of this working feature and just updated the values, I've checked the files closely to check if the main methods were changed and they were not.

Note: Yes, CORS is already enabled and I tried a lot of different configurations

Does anyone have an Idea what this can be?

POST 504 (GATEWAY_TIMEOUT)

(index):1 Failed to load [URL_ENDPOINT_C#_WEBAPI] No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin [ANGULAR_WEBSITE] is therefore not allowed access. The response had HTTP status code 504.

EDIT: Forgot to mention we do have on web.config:

 <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Content-Type, Authorization, Accept, X-Requested-With" />
        <add name="Access-Control-Allow-Methods" value="OPTIONS, TRACE, GET, HEAD, POST, PUT" />
      </customHeaders>

and on our WebApiConfig.cs on the Register Method

config.EnableCors();

Solution

  • Well, I've figured out what happened, there were a method throwing an exception then I was seeing a CORS exception. So I did change this method to and then no more exception.

    Thank you all