Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determine Mime Type for server side files
Message
De
03/11/2006 13:24:31
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01166970
Message ID:
01166976
Vues:
12
>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
Fil
Voir

Click here to load this message in the networking platform