【发布时间】:2012-04-18 22:12:09
【问题描述】:
我已经制作了一个消息系统,用户可以在其中相互发送消息,他们也可以在消息中将文件作为附件发送(就像简单的电子邮件系统一样)。 如果文件名包含空格(例如,ticket.doc 的 602_Sign 文件),我在 Firefox 中遇到问题 在 Firefox 中它会使用 602_Sign.doc 保存,但是它应该显示完整的名称,问题在 IE 和 chrome 上运行良好,下面是我下载文件的代码
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;
}
【问题讨论】:
标签: c# cross-browser http-headers