Chrome浏览器不显示由HTTP处理程序生成的图像 [英] Chrome browser does not show images generated by HTTP handler

查看:253
本文介绍了Chrome浏览器不显示由HTTP处理程序生成的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我有一个网站,使一些文档(主要是办公室)的HTML preVIEW。由此产生的HTML片段包含在同一网站返回的页面,但图像是由HTTP处理程序与以下链接返回从其他网站:

 < IMG WIDTH =50高度=50SRC =HTTP://portal/Service/GetFile.asxh ID = 123安培;内嵌=真正的>

由于某些原因,除了Chrome的所有浏览器(如IE6 / 7/8,Firefox,歌剧,Safari浏览器)显示所有的东西就好了,但是,对于这些图像显示Chrome的破碎的形象的图标。如果我选择在新标签中打开图像,然后将图像显示就好了。

修改我想我已经解决了这个问题,但显然与小提琴手打开它工作正常。

我有context.Response =UTF-8留在code,但删除它并没有区别。

标题:

  HTTP / 1.1 200 OK
日期:星期三,2011 GMT 14时26分57秒1月5
服务器:Microsoft-IIS / 6.0
MicrosoftOfficeWebServer:5.0_Pub
的X已启动方式:ASP.NET
的X ASPNET-版本:4.0.30319
传输编码:分块
缓存控制:无缓存
编译:无缓存
过期:-1
内容类型:图像/ JPEG

code:

  context.Response.ContentType = file.ContentType;                    context.Response.Cache.SetCacheability(HttpCacheability.NoCache);                    字节[] = BUFF新的字节[BUFFSIZE]
                    使用(VAR流= repository.GetFileContentsAsStream(file.ContentId))
                    {
                        INT读取动作;
                        做
                        {
                            读取动作= stream.Read(BUFF,0,BUFFSIZE);
                            如果(读取动作大于0)
                            {
                                context.Response.OutputStream.Write(BUFF,0,读取动作);
                            }
                        }而(读取动作大于0);
                    }                    context.Response.Flush();
                    context.Response.Close();


解决方案

我是pretty确保Chrome需要的长度为图像进行设置,因此尝试添加Content-Length头您的回复处理图像时

Basically I have a web site that renders HTML preview of some documents (mainly office). The resulting HTML fragment is included in the page returned by the same web site, however images are returned by HTTP handler from another site with the following links:

<img width="50" height="50" src="http://portal/Service/GetFile.asxh?id=123&inline=true">

For some reason all browsers except Chrome (e.g. IE6/7/8, Firefox, Opera, Safari) show everything just fine, however for these images Chrome shows "broken image" icon. If I choose "Open image in new tab" then the image is shown just fine.

Edit I thought I have solved this issue, but apparently with Fiddler turned on it works fine.

I had context.Response="utf-8" left in code, but removing it had no difference.

Headers:

HTTP/1.1 200 OK
Date: Wed, 05 Jan 2011 14:26:57 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Transfer-Encoding: chunked
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Content-Type: image/jpeg

Code:

                    context.Response.ContentType = file.ContentType;

                    context.Response.Cache.SetCacheability(HttpCacheability.NoCache);

                    byte[] buff = new byte[BuffSize];
                    using (var stream = repository.GetFileContentsAsStream(file.ContentId))
                    {
                        int bytesRead;
                        do
                        {
                            bytesRead = stream.Read(buff, 0, BuffSize);
                            if (bytesRead > 0)
                            {
                                context.Response.OutputStream.Write(buff, 0, bytesRead);
                            }
                        } while (bytesRead > 0);
                    }

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

解决方案

I'm pretty sure Chrome requires the Length to be set for images, so try adding the Content-Length header to your response when handling the image.

这篇关于Chrome浏览器不显示由HTTP处理程序生成的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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