Chrome, pdf display, Duplicate headers received from the server

Solution 1:

The solution above is fine if you don't need to specify the filename, but we wanted to keep the filename default specified for the user.

Our solution ended up being the filename itself as it contained some commas. I did a replace on the commas with "" and the file now delivers the document as expected in Chrome.

FileName = FileName.Replace(",", "")

Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment; filename=" & FileName)    
Response.BinaryWrite(myPDF)

Solution 2:

I used @roryok's comment, wrapping the filename in quotes:

Response.AddHeader("content-disposition", "attachment; filename=\"" + FileName + "\"")

@a coder's answer of using single quotes did not work as expected in IE. The file downloaded with the single quotes still in the name.

Solution 3:

Had this problem today. Per roryok and others, the solution was to put the filename in quotes.

Previous, Chrome FAIL:

header("Content-Disposition: attachment; filename=$file");

Current, Chrome OK:

header("Content-Disposition: attachment; filename='$file'");

Note the quotes around $file.

Solution 4:

I was having the same issue and fixed it by just removing the file name from the return statement.

Change:

 return File(outStream.ToArray(), "application/pdf", "Certificate.pdf");

to:

 return File(outStream.ToArray(), "application/pdf");

And KEPT the:

Response.AddHeader("content-disposition", "attachment;filename=\"" + "Certificate.pdf" + "\"");

This still keeps the name for the downloaded file.