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

  • 相关阅读:
    使用contentProvider
    创建Sqlite数据库(一)
    AIDL实现进程间通信
    Messenger实现进程间通信(IPC)
    Serializable使用
    Parcelable使用(二)
    STAR法则
    Python系列-------基本语法
    前端随心记---------面试题集
    前端随心记---------惟客科技面试
  • 原文地址:https://www.cnblogs.com/johnblogs/p/6639533.html
Copyright © 2011-2022 走看看