我正在玩EPPlus 2.9 http://epplus.codeplex.com/由于某种原因我得到Duplicate headers received from server
当我尝试下载单曲时出现错误.xlsx
使用 Chrome 16 的文件(在 IE9 中工作正常)。
我在用着本教程 http://www.c-sharpcorner.com/uploadfile/vendettamit/web-application-export-to-excel-advanced-using-open-source-library-epplus/我已将问题范围缩小到这行代码:
Response.AppendHeader("Content-Disposition",
"attachment; " +
"filename=\"ExcelReport.xlsx\"; " +
"size=" + fileBytes.Length.ToString() + "; " +
"creation-date=" + DateTime.Now.ToString("R") + "; " +
"modification-date=" + DateTime.Now.ToString("R") + "; " +
"read-date=" + DateTime.Now.ToString("R"));
我的用户代理:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7
我继续读下去Chrome 不喜欢逗号 (,
) in Content-Disposition
标题,它们应该用分号替换(;
).
有人有任何想法或遇到同样的错误吗?
我傻了,DateTime.Now.ToString("R")
产生Thu, 26 Jan 2012 02:05:44 GMT
我通过这样做修复了它:
String timestamp_without_commas = DateTime.Now.ToString("R").Replace(",","");
Response.AppendHeader("Content-Disposition",
"attachment; " +
"filename=\"ExcelReport.xlsx\"; " +
"size=" + fileBytes.Length.ToString() + "; " +
"creation-date=" + timestamp_without_commas + "; " +
"modification-date=" + timestamp_without_commas + "; " +
"read-date=" + timestamp_without_commas);
我已经习惯了 IE 的暴躁和 Chrome 的流畅...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)