仅限FireFox中的文件下载问题 [英] File Download issue in FireFox only
本文介绍了仅限FireFox中的文件下载问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经建立了一个消息传递系统,用户可以在其中相互发送消息,也可以在消息中作为附件发送文件(类似于简单的电子邮件系统).如果文件名包含空格(例如,ticket.doc的602_Sign文件),则我在Firefox中遇到问题在Firefox中,它将保存为602_Sign.doc,但是它应该显示完整的名称,问题在IE和chrome上运行正常,下面是我下载文件的代码
I have make a messaging system in which user can send messages to each other, they can also send files as attachement in message(its like simple email system). I am facing an issue in firefox, if file name contains space(eg 602_Sign File for ticket.doc) in firefox it'll save with 602_Sign.doc however it should display complete name,issue is working fine on IE and chrome,below is my code for downloading file
public ActionResult Download(string attFileName)
{
string FileName = Path.Combine(Server.MapPath("~/MessageAttachmentFiles"), attFileName);
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
Response.AddHeader("Content-Disposition", string.Format("attachment; filename = {0}", System.IO.Path.GetFileName(FileName)));
response.TransmitFile(FileName);
response.Flush();
response.End();
return null;
}
推荐答案
以下内容应该有效
response.AddHeader("Content-Disposition",
string.Format("attachment; filename = \"{0}\"",
System.IO.Path.GetFileName(FileName)));
有关 http://kb.mozillazine.org/Filenames_with_spaces_are_truncated_upon_download
这篇关于仅限FireFox中的文件下载问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文