Reputation: 443
string fileName = "test.txt";
byte[] docBytes = getDocumentBytes();
return File(docBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
This returns a file called "test.txt" on Firefox and Edge, however on Chrome it returns a file called "test.txt--". Does anyone know why it behaves in this manner? Is there a way to fix this in the code?
Upvotes: 1
Views: 54
Reputation: 443
Well this was hard to find out.
Chrome converts whitespace at the end of the filename into '-'.
return File(docBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName.Trim());
The trim fixes this problem.
Upvotes: 2