当前位置: 代码迷 >> ASP.NET >> 点击 LinkButton1 ,让客户下载文件,能行吗?该怎么处理
  详细解决方案

点击 LinkButton1 ,让客户下载文件,能行吗?该怎么处理

热度:5414   发布时间:2013-02-25 00:00:00.0
点击 LinkButton1 ,让客户下载文件,能行吗??
点击   LinkButton1   ,让客户下载文件,能行吗??

代码怎样写??

------解决方案--------------------------------------------------------
string name = Server.MapPath( "~/1.ascx ");
FileInfo aFile = new FileInfo(name);

Response.Clear();
Response.ClearHeaders();
Response.BufferOutput = false;
Response.ContentType = "application/octet-stream ";
Response.AppendHeader( "Content-disposition ", "attachment;filename=1.ascx ");
Response.AddHeader( "Content-Length ", aFile.Length.ToString());
Response.WriteFile(name);
Response.Flush();
Response.End();