Aru*_*nas 10 html asp.net google-chrome
基本上我有一个网站,提供一些文件(主要是办公室)的HTML预览.生成的HTML片段包含在同一网站返回的页面中,但是HTTP处理程序从另一个站点返回图像,其中包含以下链接:
<img width="50" height="50" src="http://portal/Service/GetFile.asxh?id=123&inline=true">
Run Code Online (Sandbox Code Playgroud)
出于某种原因,除了Chrome之外的所有浏览器(例如IE6/7/8,Firefox,Opera,Safari)都显示一切都很好,但是对于这些图像,Chrome显示"破碎的图像"图标.如果我选择"在新标签中打开图像",则图像显示得很好.
编辑我以为我已经解决了这个问题,但显然与Fiddler打开它工作正常.
我在代码中留下了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
Run Code Online (Sandbox Code Playgroud)
码:
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();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8917 次 |
| 最近记录: |