Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Content type for file handler

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SushiSean - 19 Dec 2007 22:23 GMT
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?
Mohamad Elarabi - 20 Dec 2007 02:45 GMT
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,

Signature

Mohamad Elarabi
Lead Developer. MCTS, MCPD.

> Hello. I have simple file handler.
>
[quoted text clipped - 10 lines]
> 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?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.