1

I am working on Angular JS app which connects to CORS .NET WEB API. The below code works fine with chrome / firefox / safari browsers but for some reason not on IE Edge (any version). I get OPTIONS pre-flight response with HTTP code 200 but subsequent post request does NOT fire.

var postData = {
           'id': 1,
           'name':'Niket'
       } 
function SendData(APIServiceUrl, postData)
{

       return $http({
           method: 'POST',
           url: URL + APIServiceUrl,
           data: postData,
           headers: { 'Content-Type': 'application/json; charset=UTF-8' }
       });
 }

If I switch the content-type to

headers: { 'Content-Type': 'application/x-www-form-urlencoded' }

then I do get the post request working. But our API Server response only allows

 Access-Control-Allow-Headers: Authorization, Content-Type

I have gone through dozens sites to solve this issue, and have tried bunch of solutions ranging from JSON.stringify(), verifying caching is disabled, syntax checking, CORS setup etc. but not able to find solution to why the POST request does NOT fire in IE Edge.

An article that I have found along similar line is this but that has not been SOLVED either --> Post JSON ajax request with cors not working in IE10/Edge.

Angular JS ver 1.5.7, IE Edge version 40.15063.0.0,

PLEASE HELP!!!

John Slegers
  • 45,213
  • 22
  • 199
  • 169
Blue Leaf
  • 11
  • 2
  • What server are you using? Have you tried responding to `OPTIONS` requests on the server level? – borislemke Jun 01 '17 at 11:16
  • @borislemke - it's IIS Web server handling requests on HTTPS. no have not since other browsers do work perfectly. Something on IE Edge...see OPTIONS request but not the subsequent POST request. Any other idea? – Blue Leaf Jun 01 '17 at 11:40
  • Can you try this answer: https://stackoverflow.com/q/9254891/871956 – borislemke Jun 01 '17 at 13:10
  • It says character encoding is redundant for `application/json`. Try to remove the encoding, try sending a non latin1 strin, e.g "hello world!". Try to find out if its failing for any request or only if certain characters are involved – borislemke Jun 01 '17 at 13:11
  • looks like it's not the encoding but the way IE handles the application/json payload. instead of json value IE Edge adds NULL to the payload. Is there a separate request object for IE ?? – Blue Leaf Jun 03 '17 at 08:40

0 Answers0