错误消息
"Requested URL: /selva/DDL COMMANDS.doc"
实际上我的文件路径应该是
URL:/selva/Docs/DDL COMMANDS.doc
我使用的代码:
LinkButton lnkbtn = sender as LinkButton;
GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
string filePath = gvDetails.DataKeys[gvrow.RowIndex].Value.ToString();
Response.ContentType = "application/doc";
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + filePath + "\"");
Response.TransmitFile(Server.MapPath("~/+ filePath + "));
Response.End();
在aspx中
任何人都可能很快帮助我。 提前谢谢。
答案 0 :(得分:0)
试试这个
Response.Clear();
Response.AppendHeader("content-disposition", "attachment; filename=xxxxxx.doc");
Response.ContentType = "Application/msword";
Response.WriteFile(Server.MapPath("/xxxxxxx.doc"));
Response.Flush();
Response.End();