My MVC-3 application has a file upload feature. The file content and content type are saved in database so that while trying to download, the correct file can be reencrypted.
Everything is working fine except that if the browser is Firefox 13 (13.0.1 I have), the content type of docx file is detected as text/plain instead of application/vnd.openxmlformats-officedocument.wordprocessingml.document.
I have checked that it works fine in IE. And now I am upgraded to Firefox 14.0.1. Its working fine too.
Now the question is, how can I determine the content type of a HttpPostedFileBase independent of browser?
Original Answer
As I understand it, MIME types are not the most reliable thing.
Personally I would ignore the browser-provided content type completely, and use server map based on
FileNameextension (not precise either, but at least similar to the experience in OS itself).After all, client can send you pretty much anything at all as a content type (dependning on the browser and, potentially, system).
Mapping extensions to Content Types
One option (as used by the question author) is to use entries in
HKEY_CLASSES_ROOT: