通常我们在做文件下载或文件导出的时候,在把二进制流文件发送到客户端之前都要为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
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
浙公网安备 33010602011771号