I have a section on a website where I display a pdf inside a light box. The recent chrome upgrade has broken this displaying:
Error 349 (net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION):
Multiple Content-Disposition headers received. This is disallowed to
protect against HTTP response-splitting attacks.
This still works correctly in IE.
I'm using ASP.NET MVC3 on IIS6
The code I use to generate the file is as follows.
If I remove the inline statement then the file downloads, however that breaks the lightbox functionality.
Problem Code
public FileResult PrintServices()
{
//... unrelated code removed
MemoryStream memoryStream = new MemoryStream();
pdfRenderer.PdfDocument.Save(memoryStream);
string filename = "ServicesSummary.pdf";
Response.AppendHeader("Content-Disposition", "inline;");
return File(memoryStream.ToArray(), "application/pdf", filename);
}
The Fix
Remove
Response.AppendHeader("Content-Disposition", "inline;");
Then Change
return File(memoryStream.ToArray(), "application/pdf", filename);
to
return File(memoryStream.ToArray(), "application/pdf");
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…