Why do ASHX asynchronous generated images not always work in IE6?

If you use a WebHandler that inherits IHttpAsyncHandler, you should not notice that under uncertain circumstances the MS IE6 browser will not display it, the request will never end. Is there a fix for it?

+3
source share
2 answers

I myself will answer it, but I decided to solve it for 3 days when I first encountered this problem.

When an image is requested through the "src" property of the HTML "img" tag, under certain conditions MS IE6 requires Content-Length to complete the request and display the result.

ASHX HTTP- Content-Length, . , , , , HTTP-, .

:

using (Image resizedImage = generateImage())
{
    using (MemoryStream memoryStream = new MemoryStream())
    {
        resizedImage.Save(memoryStream, ImageFormat.Jpeg);
        context.Response.AddHeader("Content-Length", memoryStream.Length.ToString());
        memoryStream.WriteTo(context.Response.OutputStream);
    }
}

tcpdumped , 2 :

1) 3 TCP- .

2) "Keep-Alive" ( , )

+4

HTTP , ( , ). IIRC, , , , ( , keep-alive - keep -alive, ). , ASP.NET . , , , ASP.NET, .

, , , HttpHandler, .

+1

All Articles