IIS & Chrome: failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING

后端 未结 6 1722
感情败类
感情败类 2020-12-06 00:27

I recently came across a Chrome issue which I think is worth sharing it with you.

I worked on a self written API using an HttpHandler which primary should return jso

6条回答
  •  抹茶落季
    2020-12-06 00:46

    I was running into this error when generating a file and pushing it to the user for download, but only occasionally. When it didn't fail, the file was consistently 2 bytes short. Close() forcibly closes the connection, whether it's finished or not, and in my case it was not. Leaving it out, as suggested in the question, meant the resulting file contained both the generated content as well as the HTML for the entire page.

    The solution here was replacing

    context.Response.Flush();
    context.Response.Close();
    

    with

    context.Response.End();
    

    which does the same, but without cutting the transaction short.

提交回复
热议问题