这是我的强制下载代码:
// 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 中出现的对话框显示:您将打开文件:并且文件名显示为如何(名称应为:如何使用 Application.txt)。如果我尝试为自己编写文件名,我提到的 sama:
Response.AddHeader("Content-disposition", "Attachment; Filename=How to use the Application.txt");
同样的出现。请帮忙!