Solved

ASP.NET database image handler doesn't display ICO image format

Posted on 2010-08-22
1
787 Views
Last Modified: 2013-12-25
I'm storing my images in a sql 2008 database as varbinary(max) and displaying them on my web page using an httphandler. The httphandler does the following:
context.Response.ContentType = dr("Filetype").ToString()
context.Response.BinaryWrite(DirectCast(dr("File"), Byte()))

Open in new window

where Filetype is the file extension. For example, GIF, JPG, PNG, ICO.

I use the following markup to display the image:

<asp:Image ID="Image1" runat="server" ImageUrl="~/HttpHandlers/DBImageHandler.ashx?fileid=11" />

Open in new window


The code works fine for PNG but not for ICO. I know the web site can display ICO file extensions since I was originally storing the files on web server disk drive and displaying them normally (ImageUrl='~/images/MyIcon.ico').

Do I need a different content type than ico to display those file types?

Thanks in advance.
0
Comment
Question by:ZekeLA
1 Comment
 
LVL 1

Accepted Solution

by:
ZekeLA earned 0 total points
ID: 33496000
I found the answer. Content type of .ico has to be image/x-icon. Apparently, .png doesn't require explict content type. I found correct format from this list: http://www.asptutorial.info/sscript/ContentType.html.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question