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.
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:
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:
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!