Welcome to Professional ASP.NET - Chris Love's Official Blog Sign in | Join | Help

Chris Love's Official ASP.NET Blog

Chris Love's Helpful tips, tricks and pragmatic development knowledge for the ASP.NET world.
Add to Technorati Favorites


ASP Insider Follow Me On Twitter
Designating Content Type

Another common issue developers have using HttpHandlers is indicating what type of content is being sent to the browser. This is done by setting the MIME TYPE in the request header. In ASP.NET, whether you are doing it in an HttpHandler or a Page, you can designate the Response.ContentType.

 

Response.ContentType = "text/html";

 

This content type tells the browser how to process this content. In fact I believe FireFox will need you to pass this when you send generated CSS or JavaScript to the client. If you have been to one of my HttpHandler or HttpModules user group presenations you have seen me send PDFs, vCards and more. All require setting the content type. In the case of a PDF or a vCard the browser will then know to load the appropriately mapped application (ie Foxit Reader or Outlook in my case).

You can review a whole list of common Mime types on Wikipedia. I reccomend reviewing this list if you want to get an idea of how content is designated over the web.

Posted: Thursday, September 17, 2009 10:39 AM

by Chris Love

Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS