我有这个代码:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "DownLoad")
{
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("content-disposition", "filename =" +
e.CommandArgument);
Response.TransmitFile(Server.MapPath("~/Uploads/")+e.CommandArgument);
Response.End();
}
}
代码可以工作,但它会打开.txt文档和.pdf文档,并在Web浏览器中显示它们。如果我下载了.csv或.doc文件,系统会提示我保存或打开该文件。对于所有下载的文件,我希望有保存或打开选项。