当我强迫从网页下载文件时,它通过SPACE / C#拆忒文件名? [英] When I force downloading a file from a page, it split te file name by SPACE /C#?
问题描述
下面是我的code为强制下载:
Here is my code for the Force Download:
// URL = Download.aspx?Url=How to use the Application.txt
string q = Request.QueryString["Url"].ToString();
Response.Clear();
Response.AddHeader("Content-disposition", "Attachment; Filename=" + file);
Response.ContentType = "Text/Plain";
Response.WriteFile(Server.MapPath("Directory/" + q));
Response.End();
对话框,在Firefox中apears说:你要打开的文件:
和文件名显示只是个屁如何(这个名字应该是:如何使用Application.txt)。萨玛我提到,如果我尝试赖特文件名,我的自我:
The Dialog Box that apears in Firefox says: You are going to open the file: And the filename is displayed just ass How (the name should be: How to use the Application.txt ). The sama I mentioned if I try to wright the filename for my self:
Response.AddHeader("Content-disposition", "Attachment; Filename=How to use the Application.txt");
同样apears。请帮助!
The same apears. Please Help!
推荐答案
哑剧文件名应该用双引号。
Mime files names should be double quoted.
Response.AddHeader("Content-disposition",
"Attachment; Filename=\"" + file + "\"");
内容处置:附件;文件名=fname.ext
Content-Disposition: attachment; filename="fname.ext"
修订 RFC 6266 允许不带引号文件名太多,如果他们不含有禁止charecters像的空间。
Revised in RFC 6266 to allow file names without quotes too if they didn't contain disallowed charecters like spaces.
内容处置:附件;文件名= example.html的
Content-Disposition: Attachment; filename=example.html
这篇关于当我强迫从网页下载文件时,它通过SPACE / C#拆忒文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!