Solved

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

Posted on 2010-08-22
1
783 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show banners that are blocked by Ad Muncher 10 48
SQL Login 17 40
ASP.NET 5 Templates 2 66
Office 365 Pass Username an Password in URL 3 43
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to count occurrences of each item in an array.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now