2012-03-17 128 views
1

我建立該文件的下載阿賈克斯,但返回的文件名被切斷:MVC 3文件下載切文件名

原文件名:

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

好吧,我看到這是由空白字符引起的,如果我將它改爲例如_它工作正常