a blog for those who code

Thursday 3 December 2015

[Solved] Duplicate headers received from server in Chrome

In this post we will show how to solve "Duplicate headers received from server" issue in Chrome. The error will be "The response from the server contained duplicate headers. This problem is generally the result of a misconfigured website or proxy."

The basic information about the error is net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION - Multiple distinct Content-Disposition headers received. This is disallows to protect against HTTP response splitting attacks.

This error happens because the file you are trying to download contains comma(,) or semicolon(;).

Fix 1 : Instead of directly giving the filename put quotes around the filename. So Instead of

Response.AddHeader("Content-Disposition", "attachment;filename=" + displayName); 


Response.AddHeader("Content-Disposition", "attachment;filename=\"" + displayName + "\"");

Fix 2 : Change the commas(,) and semicolon(;) from the file to underscore (_)

var validDisplayName = displayName.Replace(",", "_").Replace(";", "_");
Response.AddHeader("Content-Disposition", "attachment;filename=" + validDisplayName);

Please Like and Share CodingDefined.com Blog, if you find it interesting and helpful.

No comments:

Post a Comment