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. 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.

Share This Article With Your Friends!

We use cookies to give you the best experience possible. By continuing, we'll assume you're cool with our cookie policy.

Install Love2Dev for quick, easy access from your homescreen or start menu.

Googles Ads Facebook Pixel Bing Pixel LinkedIn Pixel