Page view counter

ASP.NET Development Server Serves Images as "application/octet-stream" Content type

Last post 03-12-2008 1:52 AM by Benson Yu - MSFT. 1 replies.

Sort Posts:

  • ASP.NET Development Server Serves Images as "application/octet-stream" Content type

    03-06-2008, 11:07 PM
    • Loading...
    • peelee33
    • Joined on 02-07-2008, 9:29 PM
    • Posts 3
    • Points 1

    Is there an easy way to set content type for the "ASP.NET Development Server" that comes with Visual Studio 2005?  I'm using the VS 2005 Standard Edition, and it serves images and almost any binary files as "application/octet-stream" which is causing all my code to fail on the development machine because it doesn't know how to serve the correct "Content-Type" header!

     

  • Re: ASP.NET Development Server Serves Images as "application/octet-stream" Content type

    03-12-2008, 1:52 AM
    Answer

    Hi peelee33,

    As far as I know, there is no way to set MIME type for the build-in ASP.NET Development Server. I would like to know why you do not want to use IIS. Change an existing web projec to use IIS as web server is easy to achieve. Please refer to my reply about how to change web server for exising web project in the following thread:

    do I need to publish my website to be able to access it via server name?
    http://forums.asp.net/t/1168282.aspx

    However, if you really don’t want to use IIS or IIS is not available on your machine, the alternative is to write a http handler to handle the image type resource and add the "ContentType" manually, such as context.Response.ContentType = "image/gif"; context.Response.ContentType = "image/jpeg", and so on. For more detailed information, please refer to the following links:

    Serving Dynamic Content with HTTP Handlers
    http://msdn2.microsoft.com/en-us/library/ms972953.aspx

    HTTP Handlers for Images in ASP.NET
    http://www.c-sharpcorner.com/UploadFile/desaijm/HTTPHandlersForImages11152005062705AM/HTTPHandlersForImages.aspx

    Sincerely,
    Benson Yu
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
Page 1 of 1 (2 items)