When you try to re-POST subsequent requests from Internet Explorer browser it only sends only the header data is posted. As a result you will receive error in response – The request body did not contain the specified number of bytes. Got 0, expected xxx. There is already a Hotfix available at Microsoft Knowledge Base https://support.microsoft.com/en-gb/kb/895954.
General Repro Steps –
- For every first XMLHttpRequest, a keep alive connection (TCP Connection) is created which is used by any subsequent request. If the connection is forcibly closed by the browser, then browsers will try to create a new connection by resubmitting the request.
- For GET Requests it will work without any issues. But for POST it will only send Request Headers and not the body in Internet Explorer. That’s why you will receive error – The request body did not contain the specified number of bytes. Got 0, expected xxx.
- As a solution either install above mentioned Hotfix or Use NEW unique URL by adding TimeStamp to URL to avoid any re-POST request.
var urlToPost = "ajaxUrlToPost.svc?stamp=' + new Date().getTime();