473,382 Members | 1,409 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,382 software developers and data experts.

Content type for file handler

Hello. I have simple file handler.

public void ProcessRequest (HttpContext context)
{
context.Response.WriteFile(FullRealPath);
}

it works but not correct. if I am tring WriteFile some zip or mp3 in browser
open it as a text! As I know I need send correct ContentType. Something like
this
context.Response.ContentType = "image/jpeg";

but how I can found this param for any file? it can be image, text, zip, mp3
anthing.... Exist any way get content type basical on exist file?
Dec 19 '07 #1
1 1574
I think the easiest way is to set it to "Application/XXX" where XXX is the
actual extension of the file you're sending. For example "Application/PDF". I
think this causes the browser to just download the file and then Windows will
figure out what application to use to run this kind of extension.

This is managed on the client from
Windows Explorer/Tools/Folder Options/File Types

Let me know if that works. Thanks,

--
Mohamad Elarabi
Lead Developer. MCTS, MCPD.
"SushiSean" wrote:
Hello. I have simple file handler.

public void ProcessRequest (HttpContext context)
{
context.Response.WriteFile(FullRealPath);
}

it works but not correct. if I am tring WriteFile some zip or mp3 in browser
open it as a text! As I know I need send correct ContentType. Something like
this
context.Response.ContentType = "image/jpeg";

but how I can found this param for any file? it can be image, text, zip, mp3
anthing.... Exist any way get content type basical on exist file?
Dec 20 '07 #2

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

Similar topics

15
by: Mike | last post by:
I'm trying to modify actual html content via the style sheet. I know there is the :before and :after tags, but I'm not quite sure how to use it and if there's another way to do it. Here's the...
2
by: Paul Rudin | last post by:
I'm have a little experiment with mod_python. I'm trying to figure out how to get hold of the original Content-Type header. In my config file I have: <Directory /var/www/test/atom> AddHandler...
1
by: Bob Jones | last post by:
I am using ASP.NET 2.0 w/ c#. I have an Http handler that intercepts any request labeled .file. I am trying to have this handler serve up a file from a remote location (public) and I do not want to...
3
by: LordHog | last post by:
Hello, How would I go about finding the default handler, let's say a text file (*.txt), then launch the default handler with the file as an argument? I had found how to launch an external...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.