多种图像处理程序调用IE造成的弹出窗口挂起 [英] Multiple image handler calls causing IE to hang in pop-up window

查看:234
本文介绍了多种图像处理程序调用IE造成的弹出窗口挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个 ASHX 图片已经在过去的几年中表现还算不错的处理程序,但我们最近注意到一些奇怪的行为间歇性的 IE8 IE9 。我们作为一个图像的src属性的一部分,这个页面是在弹出窗口中打开它调用图像处理程序多次画廊页。



页面正常工作时打开,在快速连续关闭(所有网页上的图像已完成加载之前)它会导致浏览器挂起和窗口时,但随后必须重新启动。



以下是我们的图像处理程序代码示例,我有一个怀疑,请求图像不'结束'当窗被关闭,在浏览器和服务器之间的连接仍然运行并使其崩溃。



综观日志有多次尝试通过以获得相同的图像处理程序,以便它看起来像浏览器的重试的,因为它认为它未能完成请求。



是否有任何变化,我可以做出处理程序(或客户端代码),以确保关闭浏览器窗口后不继续要求的图像,或者这是一个烤的IE的复杂性? 。Safari浏览器,Firefox和Chrome处理此类行为的罚款



阿洛斯注:显示图像的页面有网格围绕更新面板 - 但我不认为这,是有关

  Response.Clear(); 
Response.ContentType =图像/ JPEG;
为System.Drawing.Image returnImage = System.Drawing.Image.FromFile(completeImageFilePath);
使用(MemoryStream的流=新的MemoryStream())
{
returnImage.Save(流ImageFormat.Jpeg);
stream.WriteTo(Response.OutputStream);
}
returnImage.Dispose();
如果(Response.IsClientConnected)
{
Response.Flush();
}
到Response.End();


解决方案

你试过围绕<$ C $包装一用C> returnImage 来确保了.dispose()被调用?

  Response.Clear( ); 
Response.ContentType =图像/ JPEG;
使用(System.Drawing.Image对象returnImage = System.Drawing.Image.FromFile(completeImageFilePath))
{
使用(MemoryStream的流=新的MemoryStream())
{
returnImage.Save(流ImageFormat.Jpeg);
stream.WriteTo(Response.OutputStream);
}
}
如果(Response.IsClientConnected)
{
Response.Flush();
}
到Response.End();


We have an ashx image handler which has performed fairly well over the last few years, but we've recently noticed some odd intermittent behaviour in IE8 and IE9. We have a gallery page which calls the image handler multiple times as part of an image's src attribute, this page is opened in a pop up window.

The page works fine when but when the window is opened and closed in quick succession (before all the images on the page have finished loading) it causes the browser to hang and subsequently has to be restarted.

Following is a sample of our image handler code, I have a suspicion that the request to the image isn't 'ending' when the window is closed and the connection between the browser and the server is still running and causing it to crash.

Looking at the logs there are multiple attempts to GET the same image via the handler so it looks like the browser is retrying as it thinks it has failed to complete the request.

Are there any changes I could make to the handler (or the client code) to ensure the browser doesn't continue requesting the images after the window is closed or is this a baked-in intricacy of IE? Safari, Firefox and Chrome handle this type of behaviour fine.

Alos note: The page displaying the images has an update panel around the grid - but I don't think this is related.

Response.Clear();
Response.ContentType = "image/jpeg";
System.Drawing.Image returnImage = System.Drawing.Image.FromFile(completeImageFilePath);
using (MemoryStream stream = new MemoryStream())
{
    returnImage.Save(stream, ImageFormat.Jpeg);
    stream.WriteTo(Response.OutputStream);
}
returnImage.Dispose();
if (Response.IsClientConnected)
{
    Response.Flush();
}
Response.End();

解决方案

Have you tried wrapping a using around returnImage to "ensure" that .dispose() is called?

Response.Clear();
Response.ContentType = "image/jpeg";
using (System.Drawing.Image returnImage = System.Drawing.Image.FromFile(completeImageFilePath))
{
    using (MemoryStream stream = new MemoryStream())
    {
        returnImage.Save(stream, ImageFormat.Jpeg);
        stream.WriteTo(Response.OutputStream);
    }
}
if (Response.IsClientConnected)
{
    Response.Flush();
}
Response.End();

这篇关于多种图像处理程序调用IE造成的弹出窗口挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆