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();问题解决。

  • 相关阅读:
    SQL Server 索引基本概念与优化
    将Heap RID转换成RID格式
    有关DeadLock的文章列表
    sql报字段过大的错误解决方法
    查询当天数据(mysql)
    cookie和session的区别
    get和post的区别
    jq点击切换按钮最简洁代码
    js提示确认删除吗
    thinkphp解决分页后序列号自增的问题
  • 原文地址:https://www.cnblogs.com/johnblogs/p/6639533.html
Copyright © 2011-2022 走看看