Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is POST Response Data Not Received in Internet Explorer?

I have an AngularJS web app that accesses a .NET WebAPI server end. Authentication is implemented through the AngularJS-OAuth2 library. I have the app and the WebAPI hosted in localhost under two different port numbers. I have also enabled Microsoft.Owin.Cors package on the server end to handle cross-domain requests.

In Chrome, GET and POST requests return data to the front-end. By inspecting the traffic through Fiddler I could see that a pair of requests/responses are sent (preflight/OPTIONS + actual) and also the relevant CORS headers (including origin and Access-Control-* headers) in both the requests and the responses. All as expected.

However, in Internet Explorer, my GET requests return data through the $http service but the POST does not. I could inspect that there are no preflight requests or CORS headers (I think IE treats different ports as the same origin). In checking the POST request/response in IE through Fiddler I could observe that it returns HTTP status 200 but state of Aborted (with X-ABORTED-WHEN: SendingResponse flag set). I could also inspect the JSON response with the correct data returned.

I have also tried setting a high timeout to no avail. The $http call looks like this:

        return $http.post(apiUrl + "/search", service.getParameters(), { timeout: 600000 })
        .success(function (data) {...

Fiddler shows something like this for the IE POST request:

enter image description here

Also (only) in IE, an unintentional page refresh is also triggered with the same button click as this POST operation.

Why does Internet Explorer abort only the POST requests when the correct data is also returned to the client and when Chrome does not have any issues at all?

Additional Information

Request:

POST https://localhost:44321/api//search HTTP/1.1
Content-Type: application/json;charset=utf-8
Accept: application/json, text/plain, */*
Authorization: Bearer <token>
Referer: https://localhost:44322/search
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: localhost:44321
Content-Length: 202
DNT: 1
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: .ASPXANONYMOUS=<cookie>

Reponse:

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: <file>
X-Powered-By: ASP.NET
Date: Wed, 10 Feb 2016 13:43:45 GMT
Content-Length: 2284

Fiddler session properties:

SESSION STATE: Aborted.
Request Entity Size: 202 bytes.
Response Entity Size: 2284 bytes.

== FLAGS ==================
BitFlags: [IsHTTPS, ClientPipeReused, ServerPipeReused] 0x19
X-ABORTED-WHEN: SendingResponse
X-CLIENTIP: 127.0.0.1
X-CLIENTPORT: 41889
X-EGRESSPORT: 41890
X-HOSTIP: ::1
X-PROCESSINFO: avp:3584
X-RESPONSEBODYTRANSFERLENGTH: 2,284
X-SERVERSOCKET: REUSE ServerPipe#168

== TIMING INFO ============
ClientConnected:    19:13:42.408
ClientBeginRequest: 19:13:42.444
GotRequestHeaders:  19:13:42.444
ClientDoneRequest:  19:13:42.772
Determine Gateway:  0ms
DNS Lookup:         0ms
TCP/IP Connect: 0ms
HTTPS Handshake:    0ms
ServerConnected:    19:13:42.413
FiddlerBeginRequest:    19:13:42.772
ServerGotRequest:   19:13:42.772
ServerBeginResponse:    19:13:45.360
GotResponseHeaders: 19:13:45.360
ServerDoneResponse: 19:13:45.360
ClientBeginResponse:    19:13:45.360
ClientDoneResponse: 19:13:45.360

    Overall Elapsed:    0:00:02.915

The response was buffered before delivery to the client.

== WININET CACHE INFO ============
This URL is not present in the WinINET cache. [Code: 2]
* Note: Data above shows WinINET's current cache state, not the state at the time of the request.
* Note: Data above shows WinINET's Medium Integrity (non-Protected Mode) cache only.
like image 845
Tru Avatar asked Oct 19 '22 15:10

Tru


1 Answers

I believe you get bitten by the P3P policy requirement of IE here:

Internet Explorer supports a cookie-restricting privacy feature called P3P. Web developers often get tripped up by it because no other browser implements the P3P standard.

It seems similar to those QAs:

  • CORS request with IE11

  • CORS doesn't work with cookies in IE10

  • Internet Explorer 10 is ignoring XMLHttpRequest 'xhr.withCredentials = true'

Here's a blog post with an example how to send P3P information. Here's a document from Microsoft about P3P configuration

like image 174
Johannes Jander Avatar answered Oct 21 '22 06:10

Johannes Jander