MVC 3文件下载剪切文件名

时间:2012-03-17 08:50:41

标签: asp.net-mvc-3

我正在构建文件的Ajax下载,但是返回的文件名已被删除:

原始文件名:

Toksykologia - wyklady 2010.doc.pdf

浏览器已下载:

Toksykologia

代码

HttpResponseBase response = HttpContext.Response;
FileInfo TheFile = new FileInfo(filePath);
response.Clear();

cookie.Value = "success";

response.SetCookie(cookie);
response.Buffer = true;
response.AddHeader("content-disposition", "attachment;filename=" + TheFile.Name);
response.Charset = "";
response.ContentType = "application/pdf";
response.WriteFile(TheFile.FullName);
response.Flush();
response.End();

1 个答案:

答案 0 :(得分:1)

好的,我看到这是由空格char引起的,如果我将其更改为例如_它运作正常