Downloading Office 2007 documents from IIS 6
filed in Asp.net, C# on Dec.06, 2007
Today at work, I had to make a small asp.net form that enables the user to apply for a job and upload their resume. In the backoffice that I made, the admin has the possibility to view all applicants and download the files they’ve uploaded. Possible file types are .pdf, .doc and .docx. While testing this application, I had uploaded a Word file and checked via FTP that the upload including the renaming of the file and moving it to the correct folder went fine. So, as a final test, I tried to download the uploaded file via my browser, just like the admin would do when te application went live. This didn’t work at all! The server just returned a 404 Not Found error page. I tried for maybe half an hour and started to think I was going crazy. I could see the file through FTP, but could not download it. How is that possible!?
Then, after half an hour, I did what I should have done all along. I renamed the file from the Microsoft Word 2007 file extension .docx to a regular .doc and it worked instantly! After a few seconds looking in Google, I realized that IIS6.0 (which runs on our hosting provider’s server) is Secure By Design. This means that MIME types are in a white list. Everything that isn’t known to the server is hidden by default and thus returns a 404 error.
To solve this problem, you have to add a MIME type to IIS. To do this, you just follow these simple steps:
- In the Internet Management console, you go to the properties of the web site, by right clicking onto it.
- Under “HTTP Headers”, “Mime Types”, you add a new extension (without the leading dot) with the mime type “application/vnd.openxmlformats-officedocument.wordprocessingml.document”.
You can find a complete list of mime types for office 2007 documents on the Microsoft website.
December 10th, 2007 on 12:46
Geloof het of niet, maar dat kon ik u ook vertellen
December 10th, 2007 on 12:50
Believe it or not, maar ik kon je dat ook vertellen
May 22nd, 2009 on 20:49
Your blog is very interresting for me, i will come back here..