访问输出为空ashx文件firefox弹出保存文件对话框
用firefox浏览器访问空的ashx文件时,会弹出保存ashx文件的对话框,“正在打开ashx”。
用开发工具监视后发现响应头尽然没有content-type类型,而且用代码强制设置content-type也无效,还是没有content-type响应头。
public void ProcessRequest(HttpContext context) { context.Response.AddHeader("content-type", "text/html");//用代码设置content-type也无效,不会发送到客户端 } public bool IsReusable { get { return false; } }
后面强制添加content-length为0后,就没问题了。⊙﹏⊙b汗。。
public void ProcessRequest(HttpContext context) { context.Response.AddHeader("content-length", "0");//添加content-length为0,firefox才会接受到响应头content-type context.Response.AddHeader("content-type", "text/html"); } public bool IsReusable { get { return false; } }
加支付宝好友偷能量挖...
原创文章,转载请注明出处:访问输出为空ashx文件firefox弹出保存文件对话框