There is my problem. I'm trying to download file from asp.net project directory. File is in "Date" directory. I have done WebForm1.aspx page with GridView that display files in Date directory. All files is displaying like a link.
There is my code bottom.
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName == "Download")
{
Response.Clear();
Response.ContentType = "text/plain";
Response.AppendHeader("content-disposition", "filename" + e.CommandArgument);
Response.TransmitFile(Server.MapPath("~/Data/") + e.CommandArgument);
Response.End();
}
}
I go through the link with file. After that my browser offer to download not my file but the file of all page (WebForm1.aspx) Help me solve this problem. What have I done incorrect?
您的处理标头很奇怪(没有attachment
,缺少=
),更改为:
Response.AppendHeader("content-disposition", "attachment; filename=" + e.CommandArgument);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.