Today we were called to fix a strange issue that was happening to one of our colleagues when trying to download a PDF file from one of our Document Management Systems. The error was related to a single file and sounded like this:
This page isn't working
(the website) sent an invalid response.
ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION
That sounded quite strange, especially considering the fact that a lot of other files - same extension, same size and so on - was working fine.
We found the solution rather quickly by finding this StackOverflow thread, which luckily enough pointed us to the right direction. The issue was related to a single "comma" in the filename as defined in the Content-Definition header, which was programmatically defined in the back-end code:
1 |
Response['Content-Disposition'] = 'attachment; filename=file,name.pdf'; |
It's worth noting that, even if the mentioned SO topic was related to Django, it's definitely an universal issue: we were getting it with ASP.NET C# as well.
Anyway, the proper solution was to encompass the filename with double quotes, thus avoiding HTTP header mismatches:
1 |
Response['Content-Disposition'] = 'attachment; filename="file,name.pdf"'; |
That's pretty much about it. I hope that this quick fix will help those who'll be stuck with this issue as well!
If you guys did not share it I would never figure out what was the problem with my code. That is the importance of sharing solutions. Thank you.
Just another comment from the internet saying that this post helped save a lot of stress!!
pff.. thank Ryan ;)
Thank you, Ryan, You are my hero.
Thanks to you! If you’ve found our blog useful, don’t forget to like us on FB and Twitter :)
Thanks Ryan! Saved me a lot of time…
Wow, one Google on the response header and there is your solution. Thanks so much for sharing it!
Love u man!