asp.net - Firefox response.redirect 不适用于文件

标签 asp.net vb.net firefox

我试图允许用户使用

下载 Excel 文件
Response.Redirect(
    "http://localhost/myapp/download_folder/example excel file_july.xls") 

在 ASP.net 页面的页面加载中

但在客户端,我在 Firefox 3.5 中看到以下屏幕

Firefox 3.5 shows blank download screen

您可以观察到文件名和文件类型显示为空字段。确定和取消按钮没有执行任何操作。

这只发生在 Firefox 3.5 中,它可以在 Firefox 更高版本和其他浏览器中工作。

我尝试使用 Response.Clear() 清除响应,使用 Response.BinaryWrite 与文件字节数组,甚至尝试通过调用使用 javascript 打开文件window.open(url)。

最佳答案

你的做法是错误的。

举个例子,看看这里的问题正文做了什么:

How to download file and reload

在您的情况下,您可能应该使用 Response.Write 的重载。

重点是你应该设置一些响应头来至少告诉浏览器文件名、文件长度和内容类型。

关于asp.net - Firefox response.redirect 不适用于文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7038044/

相关文章:

javascript - 获取asp :checkbox inside a datalist using jquery的id

c# - 从 url 值导航 gridview 页面

c# - 如何在 C# 中像 Visual Basic 一样使用 Lib

vb.net - 尝试打开 Excel 模板并重命名或保存到新位置

html - TD 边框无法在 Firefox 中正确呈现

asp.net - 这是什么编码,以及如何解码它?

asp.net - 带条件的 SQL Group By

vb.net - 为什么 string.join 在 VB.Net 中返回列表对象

html - 在 Firefox 2 中设置 <select> 的高度

php - 如何使用firebug进行调试并显示单选按钮的值