>Hello Team,
>
>I have a restricted folder that i am allowing authorized downloading from through a response.binarywrite fairly straight forward stuff. What I would like to do is get the content type for the file server side before I try to do the write. So i can set my Response.ContentType = "xx" correct without relying on the file extension and a big switch statement.
>
>My humble thanks in advance,
Joe,
The file extension is the easiest way to identify the mime type. The alternative is to read some bytes from the file and match them to a list of header structures - a real PITA. Also, IIS does not maintain mime type metadata for every file in the web site. It uses the file extension too.
I do not know any .net function to return the MIME type based on a passed extension. I think that you will have to write a big switch statement. This is a function that can go into your Utility library, so you only have to write it once.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement