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