We have recently had an issue with Safari appending a ".txt" extension to downloaded files on our Umbraco site. We managed to find a solution and were encouraged to add it to the forum by Umbraco support, so here it is:
The problem:
Safari is appending ".txt" extension to all downloads of unknown format. In our case, we had files with ".asc" extenstion and the resulting file was renamed to "filename.asc.txt".
The solution:
As it turns out, Safari adds this extension based on the mime type in the Content-Type HTTP header. In our case, the Content-Type for .asc files was always text/plain, causing Safari to interpret the file as a ".txt". The solution was to add the following rewrite rules to the IIS Web.config:
The first rule changes the mime type of ".asc" files to "application/octet-stream" which forces Safari to interpret it as a binary file and thus not rename it. The second rule adds a Content-Disposition header which tells browsers that the file should be downloaded rather than viewed in the browser.
Safari appending .txt to downloads
Hello,
We have recently had an issue with Safari appending a ".txt" extension to downloaded files on our Umbraco site. We managed to find a solution and were encouraged to add it to the forum by Umbraco support, so here it is:
The problem: Safari is appending ".txt" extension to all downloads of unknown format. In our case, we had files with ".asc" extenstion and the resulting file was renamed to "filename.asc.txt".
The solution: As it turns out, Safari adds this extension based on the mime type in the Content-Type HTTP header. In our case, the Content-Type for .asc files was always text/plain, causing Safari to interpret the file as a ".txt". The solution was to add the following rewrite rules to the IIS Web.config:
The first rule changes the mime type of ".asc" files to "application/octet-stream" which forces Safari to interpret it as a binary file and thus not rename it. The second rule adds a Content-Disposition header which tells browsers that the file should be downloaded rather than viewed in the browser.
Hope this will help someone in the future!
is working on a reply...