产生的图像基本上我有一个网站,使一些文档(主要是办公室)的HTML预览。生成的HTML片段包含在同一网站返回的页面,但图像是由HTTP处理程序从其他网站使用以下链接返回:Chrome浏览器不显示通过HTTP处理程序
<img width="50" height="50" src="http://portal/Service/GetFile.asxh?id=123&inline=true">
出于某种原因,除了浏览器(如IE6/7的所有浏览器/ 8,Firefox,Opera,Safari)显示一切正常,但对于这些图像Chrome显示“图像损坏”图标。如果我选择“在新选项卡中打开图像”,则图像显示得很好。
编辑我以为我已经解决了这个问题,但显然与小提琴手打开它工作正常。
我不得不context.Response =“UTF-8”左中的代码,但除去其上没有差异。
页眉:
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
代码:
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();
请问您处理程序设置正确的内容类型? – 2011-01-05 13:57:11
您的处理程序在响应中发送什么标题? – 2011-01-05 13:57:30
您是否绝对肯定您的服务正在生成正确的标题?我以前遇到过类似的问题,而且几乎一直是头文件或流的问题,有些浏览器会原谅其他人不会的东西。我假设你的意思是“ashx的”,而不是“asxh” :) – 2011-01-05 13:58:11