MIME type detection

G

Guest

I'm writing a web application that fetches documents from the server and
sends them to the client. I do this using the Response.BinaryWrite method.

However, is there any way to detect the MIME type of a given file? Or a
catch-all MIME type I could use? These files will likely mainly be word and
pdf documents, but they can conceivably be anything.
 
K

Kevin Spencer

Hi Michael,

This is going to be a bit problematic, as MIME types are registered for
some, but not all file types. As to whether the browser will recognize a
given MIME type, that is also somewhat iffy, depending upon the browser, and
the ubiquitousness of the individual MIME type. Some are much more common
than others.

There is no class that will figure out a MIME type from a file extension,
but you could ostensibly write your own. Here is an excellent reference on
the available registered MIME types:

http://www.iana.org/assignments/media-types/

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top