Response下载文件

使用Response下载文件

1、Response.Redirect("http://localhost/模板.xls");

2、   string strFileName = Server.UrlEncode("模板");

        System.Web.HttpContext.Current.Response.Clear();

        System.Web.HttpContext.Current.Response.Buffer = true;

        System.Web.HttpContext.Current.Response.Charset = "utf-8";

        System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" +  strFileName + ".xls");

        System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");

        System.Web.HttpContext.Current.Response.ContentType = "application/ms-excel";

   System.Web.HttpContext.Current.Response.End();


做个备忘,不要老忘记了 

posted on 2008-11-16 00:19  齐世昌  阅读(1679)  评论(2编辑  收藏  举报