zoukankan      html  css  js  c++  java
  • IE下载时提示无法下载,重试后成功

    DataGrid dg = new DataGrid();
                dg.DataSource = dtSource;
                dg.DataBind();

                Response.Clear();
                Response.Charset = "UTF-8";//GB2312
                Response.ContentType = "application/vnd.ms-excel";//text/csv
                Response.ContentEncoding = System.Text.Encoding.UTF8;
                Response.AppendHeader("Content-Disposition", "attachment;filename=JobStorage.xls");

                System.IO.StringWriter oSW = new System.IO.StringWriter();
                HtmlTextWriter oHW = new HtmlTextWriter(oSW);
                dg.RenderControl(oHW);
                Response.Write(oSW.ToString());
                Response.Flush();
                //Response.Close();
                Response.End();

    IE10以上会严格校验Content-Length和Transfer-Encoding,盲目使用 Response.Close();会导致直接切断,浏览器到服务器端的套接字连接,会产生数据到丢失,而导致实际传输长度和指定不一致,clicks Retry后IE将不在严格校验,所以重试之后正常下载,低端到IE版本没有严格校验到问题如:IE8。所以将Response.Close();更改为Response.End();问题解决。

  • 相关阅读:
    Ubuntu Server下docker实战 02: docker进阶配置
    Ubuntu Server下docker实战 01: 安装docker
    简单一个方法实现商品组合管理--递归笛卡尔
    Little-Endian小字节序
    BinaryWriter和BinaryReader用法
    C#位运算
    TCP协议三次握手过程分析
    简述HTTP过程
    c# 版贪食蛇
    今日头条列表json
  • 原文地址:https://www.cnblogs.com/johnblogs/p/6639533.html
Copyright © 2011-2022 走看看