我有此代码:
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文件,则会提示我保存或打开该文档。我想为所有下载的文件提供保存或打开选项。