‘Duplicate headers received from server’ Error in Chrome 16 with EPPlus 2.9

calendar_today Asked Jan 26, 2012
thumb_up 9 upvotes
history Updated April 16, 2026

Question posted 2012 · +5 upvotes

I’m playing around with EPPlus 2.9 and for some reason I’m getting Duplicate headers received from server errors when I try to download single .xlsx files using Chrome 16 (It works fine in IE9).

I’m using this tutorial and I’ve narrowed down the problem to this line of code:

        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"));

My useragent:

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7

I read on this Chrome forum page that Chrome doesn’t like commas (,) in Content-Disposition headers and they should be replaced with semicolons (;).

Anybody got any ideas or getting the same errors?

Accepted answer +9 upvotes

I’m dumb, DateTime.Now.ToString("R") produces Thu, 26 Jan 2012 02:05:44 GMT

I fixed it by doing this:

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);

I’m used to IE being cranky and Chrome playing nice…

Top excel Q&A (6)

+9 upvotes ranks this answer #91 out of 167 excel solutions on this site .