ASP文件下载问题
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/html";
string strFilePath = context.Request.MapPath("/download/常用电话一览表.xlsx");//服务器文件路径
FileStream fs = new FileStream(strFilePath,FileMode.Open);
long filesize = fs.Length;
byte[] filebuffer=new byte[filesize];
fs.Read(filebuffer, 0, (int)filesize);
fs.Close();
context.Response.ContentType = "application/octet-stream";
context.Response.AppendHeader("Content Disposition","attachment;filename="+HttpUtility.UrlEncode(strFilePath,System.Text.Encoding.UTF8));
context.Response.AddHeader("content-Length", filesize.ToString());
context.Response.BinaryWrite(filebuffer);
context.Response.End();
context.Response.Close();
context.Response.Write(h);
}
我的download.ashx程序这么写的,但是执行后下载的是download.ashx这个文件而不是《常用电话一览表.xlsx》这是为啥呀,初学,望指教