日期:2014-05-17  浏览次数:20381 次

服务器启用了gizp,下载的excel模版会出现问题,怎么解决?
服务器相关参数:
IIS6.0
.net frmework3.5
启用IIS gzip压缩网站,压缩的参数里面没有包含xls后缀名

没有启用gizp时下载是正常了,启用了gizp就出现表头不见了,网上查找了下http://www.cnblogs.com/ppchen/archive/2009/02/19/1382530.html 里面是使用HttpModule
只有使用HttpModule这种方法吗?


下载文件代码

    /// <summary>
    /// 下载指定路径文件
    /// </summary>
    /// <param name="path">文件绝对路径</param>
    public static void DownLoadFile(string path, string oldFileName)
    {
        System.IO.FileInfo fi = new System.IO.FileInfo(path);
        if (fi.Exists)
        {
            //判断文件是否正在使用
            try
            {
                using (System.IO.FileStream fs = System.IO.File.Open(path, System.IO.FileMode.Append, System.IO.FileAccess.Write, System.IO.FileShare.None))
                {
                }
            }
            catch (Exception)
            {
                throw;
            }

            if (string.IsNullOrEmpty(oldFileName))
                oldFileName = path.Substring(path.LastIndexOf("\\") + 1);

            string browser = System.Web.HttpContext.Current.Request.UserAgent.ToUpper();
            if (browser.Contains("FIREFOX") == true)
                oldFileName = "\"" + oldFileName + "\"";
            else if (browser.Contains("MSIE"))