473,808 Members | 2,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Auto detect content-type

Hello,

I wanted to use Response.Transm itFile 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 3579
MIME types are usually recognized by the file extension. When the file
extension doesn't match the MIME type, the Response.Conten tType 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.Conten tType 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.Transm itFile 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
2287
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 article was posted by author's request Articles individually checked for conformance to usenet standards Topic URL: http://www.dbForumz.com/PHP-auto-detect-CLI-ftopict169501.html Visit Topic URL to contact author (reg. req'd). Report abuse:...
7
22756
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 be appreciated. Thanks, Brian
1
7603
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 code. Dim objPreReq As PDCPreReq.PreReqs Dim objProxy As System.Net.WebProxy = System.Net.WebProxy.GetDefaultProxy objProxy.Credentials = System.Net.CredentialCache.DefaultCredentials
1
2282
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 would you get the iframe to expand to show the now visible content and also contract if it was hidden? thanks in advance
4
12551
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' cellpadding='0' cellspacing='0' style='border-collapse:collapse; width:100%; height:100%;'> <tr><td colspan='2' style='height:3em; border-bottom:1px solid
2
3124
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
2983
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 table to dictate the height to the content div instead of popping out of the bottom of the content div. Seems pretty simple but too complicated for me I guess. If you know how to achieve this please share. Thanks, J /*begin code*/
11
10756
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 a remote IMAP/POP3 server so that I can connect and fetch mail for the user. (Ultimately, I don't want users to have to know what the IMAP/POP3 server name / port is .... I would like to auto-detect all of that). At first I thought I could use...
9
6438
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 DepartmentID. So something like:
11
10243
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 the agent and retrieve it's MIB, so that the user do not need to enter the IP address of the agent. Beside that, I also look for the solution that can detect the nodes that had switch on or switch off in C# coding. Wish can get the solution for these...
0
10631
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10114
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9196
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.