Asp.net VS内置web服务器将图像作为八位字节流发送
我正在使用Visual Studio 2008 development web server调试一个ASP.NET网站,该网站有很多Java脚本和图像 许多脚本中的一个试图创建Asp.net VS内置web服务器将图像作为八位字节流发送,asp.net,javascript,visual-studio,http-headers,vs-devserver,Asp.net,Javascript,Visual Studio,Http Headers,Vs Devserver,我正在使用Visual Studio 2008 development web server调试一个ASP.NET网站,该网站有很多Java脚本和图像 许多脚本中的一个试图创建属性。但是,没有加载任何图像,而是在Firefox、IE和Opera中显示alt文本 进一步挖掘,我复制了一个图像链接,然后将其粘贴到Firefox的地址栏中,这就是live headers窗口中出现的内容: GET /images/nav/zoomin.png HTTP/1.1 Host: localhost:7777
属性。但是,没有加载任何图像,而是在Firefox、IE和Opera中显示alt文本
进一步挖掘,我复制了一个图像链接,然后将其粘贴到Firefox的地址栏中,这就是live headers窗口中出现的内容:
GET /images/nav/zoomin.png HTTP/1.1
Host: localhost:7777
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
HTTP/1.x 200 OK
Server: ASP.NET Development Server/9.0.0.0
Date: Wed, 25 Feb 2009 16:59:23 GMT
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: application/octet-stream
Content-Length: 292
Connection: Close
有问题的部分是内容类型
标题,它以某种方式设置为“应用程序/八位字节流”,强制执行下载操作,而不是在
标记中正常显示
我确信问题不在于javascript,因为它是从另一个运行良好的应用程序中逐字复制的代码
我想我可能在什么地方误解了什么。但我可能错了,下面是创建HTML标记的代码:
var zin = document.createElement("img");
zin = $Img.Png(zin, Settings.ImageHost + "zoomin.png");
zin.style.top = (this.y + zoomPaddingY) + "px";
zin.style.left = (this.x + zoomPaddingX) + "px";
zin.style.position = "absolute";
$Img.Swap(zin, Settings.ImageHost + "zoomin.png", Settings.ImageHost + "zoomin_active.png");
zin.alt = zin.title = "zoom in";
zin.style.cursor = this.hand;
$Evt.addListener(zin, "click", this.zoomIn, this, true);
// long long scroll ...
controlDiv.appendChild(zin);
$Img.Png
部分对于其他Png图像工作正常,因此它不应该是问题的根源
我做错了什么
谢谢你的帮助
现在已经是午夜了。。。我还在开发这个小应用程序…你是在使用一个通用的处理器来渲染图像吗
这样做似乎很容易
例如
public class RenderImage : IHttpHandler, IReadOnlySessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "image/png";
context.Response.Clear();
// TODO: Write image data
Bitmap bitmap = ...
bitmap.Save(Response.OutputStream,ImageFormat.Png);
context.Response.End();
}
public bool IsReusable { get { return false; } }
}