且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

[Fiddler] Error:Content-Length mismatch: Request Header indicated 16 bytes, but client sent 0 bytes.

更新时间:2021-08-14 08:02:39

[Fiddler] Error:Content-Length mismatch: Request Header indicated 16 bytes, but client sent 0 bytes.

 

The error is because of do "location.reload();" after "$.ajax()".

Remove "location.reload();" will fix the issue.

 

 $.ajax({
                type: 'POST',
                url: pageUrl,
                data: JSON.stringify(parameter),
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                success: function (data) {
                    onSuccess(data);
                },
                error: function (data, success, error) {
                    alert("Error : " + error);
                }
            });

 

Another same cause error:
2299 Failed to obtain request body. System.IO.InvalidDataException The request body did not contain the specified number of bytes. Got 0, expected 19

 

So how to do refresh page after ajax:

$.ajax({
                type: 'POST',
                url: pageUrl,
                data: JSON.stringify(parameter),
                contentType: 'application/json; charset=utf-8',
                dataType: 'json',
                success: function (data) {
                    onSuccess(data);
                },
                error: function (data, success, error) {
                    alert("Error : " + error);
                },
                complete: function () {
                    setTimeout(function () {
                        window.location.reload();
                    }, 1000);
                }
            });