【发布时间】:2011-03-28 11:37:54
【问题描述】:
我正在尝试从一个 aspx 页面向 Firefox 提供一个 exe。 aspx 页面处理标题,页面由我们的 Flex GUI 启动。 Flex 正确启动所有浏览器(包括 Firefox)的链接,所以我确定这不是问题。
我遇到的问题是,当我尝试从 Firefox 中下载文件时,FF 可以正常下载文件,但将其命名为“内容”。它没有扩展名,文件名不正确。所有其他浏览器都使用我在 aspx 页面中指定的文件名下载它,并且它们都具有 .exe 扩展名。我应该注意,如果我将“Content”文件重命名为“Content.exe”,它会正常运行。
下面是我在我的 aspx 页面中使用的代码 -
protected void Page_Load(object sender, EventArgs e) {
string fileName = Request.QueryString["file"];
System.IO.FileInfo fileInfo = new System.IO.FileInfo(Server.MapPath(fileName));
Response.Clear();
if ( fileName.EndsWith(".exe") ) {
Response.ContentType = "application/exe";
}
else {
Response.ContentType = "application/octet-stream";
}
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name);
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.WriteFile(fileInfo.FullName);
Response.Flush();
}
关于为什么这在 Firefox 中不能正常工作的任何想法和/或建议?
【问题讨论】:
-
这种情况下可执行文件的实际名称是什么?
-
文件名为“SwfTest.exe”