0

错误信息

"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 中

任何人都可以尽快帮助我,这可能是什么错误。提前致谢。

4

1 回答 1

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();

参考链接

于 2013-07-25T17:18:09.443 回答