1

I'm trying to do an HTTP request with the following headers:

headers.append("Content-Type", "text/xml; charset=utf-8");
headers.append("SOAPAction", "<domain>/<function-name>");

which triggers a preflight request.

On the server side I'm running IIS 7.5.x and an .asmx service. I can get everything to work if I run Chrome without web security. I already set "Access-Control-Allow-Headers" and "Access-Control-Allow-Origin", reducing the "error volume". I so wish there was a web.config setting for this to just make it work.

See also this answer but in the context of AngularJS: https://stackoverflow.com/a/33662315/1613772

Community
  • 1
  • 1
Pascal
  • 125
  • 1
  • 15

1 Answers1

2

The preflight request is made by the browser without Angular2 having any saying in it. So basically the answer is no.

One way around that works in simple cases is to use JSONP

https://angular.io/docs/ts/latest/guide/server-communication.html#!#cors

You might need to add POST to Access-ControlAllow-Methods

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • 1
    Thank you for the direction. But an .asmx service has to have an XML body in the request. As far as I know there is no way to simply switch "something" so that you can use JSONP. – Pascal Dec 03 '16 at 16:52