Sye*_*idi 0 c# cross-browser http-headers
我制作了一个消息系统,用户可以在其中相互发送消息,他们也可以在消息中将文件作为附件发送(就像简单的电子邮件系统一样).我在firefox中遇到一个问题,如果文件名包含空格(例如,对于ticket.doc为602_Sign文件)在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;
}
Run Code Online (Sandbox Code Playgroud)
以下应该有效
response.AddHeader("Content-Disposition",
string.Format("attachment; filename = \"{0}\"",
System.IO.Path.GetFileName(FileName)));
Run Code Online (Sandbox Code Playgroud)
有关http://kb.mozillazine.org/Filenames_with_spaces_are_truncated_upon_download的原因的详细信息
| 归档时间: |
|
| 查看次数: |
3637 次 |
| 最近记录: |