Link to home
Start Free TrialLog in
Avatar of ZekeLA
ZekeLAFlag for United States of America

asked on

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

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.
ASKER CERTIFIED SOLUTION
Avatar of ZekeLA
ZekeLA
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial