天边无尽头

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
通常我们在做文件下载或文件导出的时候,在把二进制流文件发送到客户端之前都要为HTTP头加上一此属性:

HttpContext.Current.Response.Clear(); 
HttpContext.Current.Response.Buffer 
= true
HttpContext.Current.Response.Charset 
="gb2312"
HttpContext.Current.Response.AppendHeader(
"Content-Disposition","attachment;filename="+file_name); 
HttpContext.Current.Response.ContentEncoding 
= System.Text.Encoding.GetEncoding("gb2312"); 
HttpContext.Current.Response.ContentType 
= "application/ms-excel"
//HttpContext.Current.Response.ContentType = "text/HTML"; 
//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword 
posted on 2007-06-22 10:56  张林  阅读(1300)  评论(0)    收藏  举报