angular-upload icon indicating copy to clipboard operation
angular-upload copied to clipboard

IE9 - Returning a non-200 code from the server causes "Access Denied"

Open lwblackledge opened this issue 11 years ago • 1 comments

I'm using this on a site that needs to be IE9 compatible and noticed an issue recently:

If you return an error code during the upload, for example 400 Bad Request then IE replaces the contents of the iframe with it's own error message (at this URI res://ieframe.dll/http_500.htm). This changes the domain of the iframe, and the following line fails:

var doc = this.contentWindow ? this.contentWindow.document : this.contentDocument;

This makes response null, and the promise to return null for the data property.

The workaround I had to do was to return a 200 from the server and then check my JSON response for an error property.

I am not sure if there is even a way around this, so maybe it should just be an update to the docs noting that the server should return 200 always, and error handling is up to the angular code?

Thanks!

lwblackledge avatar Jun 23 '15 19:06 lwblackledge

This caught me out as well; It's due to IE's "Friendly Error Messages".

IE will only display the "friendly" messages if the following two conditions are met:

  1. The HTTP Status code must be [400, 403, 404, 405, 406, 408, 409, 410, 500, 501, 505]
  2. The HTTP Response body’s byte length must be shorter than a threshold value (512 bytes)

We solved it by ensuring the response body was padded out to be at least 512 bytes.

More info here: http://blogs.msdn.com/b/ieinternals/archive/2010/08/19/http-error-pages-in-internet-explorer.aspx

peterhodges avatar Sep 07 '15 09:09 peterhodges