473,378 Members | 1,394 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Auto detect content-type

Hello,

I wanted to use Response.TransmitFile to return an image instead of a
HTML page. Under IE everything works well, but under Mozilla/Firefox the
image is treated as it were text/html.

When I set up content-type in response to image/jpeg everything works well.

But I would like to send any file instead of an image and thus I cannot
always know the proper content type. Is it possible to "autodetect" a
file content type? Or make IIS perform an "invisible redirect"
(something like Server.Execute but with local path name instead of URL)
so that default IIS mechanisms of content-type detection were used?

Thanks
Grzegorz Kaczor
Nov 19 '05 #1
1 3555
MIME types are usually recognized by the file extension. When the file
extension doesn't match the MIME type, the Response.ContentType header must
be set, to let the browser know. So, if you want to "autodetect" the MIME
type, you're going to have to do one of the following:

1. Read the file extension
2. Know what the type of file is by some other means

Then you have to set the Response.ContentType to that MIME type in the
Response.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Grzegorz Kaczor" <gr*************@cc.com.pl> wrote in message
news:cu**********@nemesis.news.tpi.pl...
Hello,

I wanted to use Response.TransmitFile to return an image instead of a HTML
page. Under IE everything works well, but under Mozilla/Firefox the image
is treated as it were text/html.

When I set up content-type in response to image/jpeg everything works
well.

But I would like to send any file instead of an image and thus I cannot
always know the proper content type. Is it possible to "autodetect" a file
content type? Or make IIS perform an "invisible redirect" (something like
Server.Execute but with local path name instead of URL) so that default
IIS mechanisms of content-type detection were used?

Thanks
Grzegorz Kaczor

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: steve | last post by:
How can I detect in php that I am running from CLI (command line), and not the browser. I hate to put a constant in each script: e.g. define(’CLI’, 1)... -- http://www.dbForumz.com/ This...
7
by: Brian | last post by:
hello, I am looking for a way to auto refresh a web page that I created, but also let the user choose to stop the auto refresh. I can not figure out how to stop the auto refresh. Any help would...
1
by: Steve.Goodman | last post by:
Appologies if this has already been asked, but after scanning the web and this news group I could find no decent solution. We have a windows App that calls a webservice, using this bit of basic...
1
by: libsfan01 | last post by:
hi all! how can you get an iframe to automatically expand vertically to show the entire contents of the page. for example if that page contained content that was shown or displayed onclick how...
4
by: reycri | last post by:
I have a page that works as I intend in IE but not in Firefox: <html> <head> <title>Overflow Test</title> </head> <body style='overflow:hidden; margin:0; padding:0;'> <table border='0'...
2
by: Ehud Banai | last post by:
Hi All, Is there any script or dll that allows me to do auto correction to digital pictures from PHP? Thanks in advance, Ehud
1
by: neridaj | last post by:
Hello, I've found a few postings of this problem but none of the answers seem to fix my problem. I have a content div wrapped around a left floated image and a right floated table. I want the...
11
by: mp- | last post by:
I want to be able to allow people to check their email from my PHP online application. Given only the users 1) email address, 2) username (if applicable) and 3) password - how can I auto detect...
9
by: DotNetNewbie | last post by:
Hello, I need a simple hash algorithm that will detect duplicate content in my application. I want to hash not just the content, but a few other parameters also like EmployeeID and...
11
by: jellychai | last post by:
I'm doing the final year project that related to the SNMP. I need to find the solution for the IP auto detection in C#. When I run the main project, the program can automatically detect the IP for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.