Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

759 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

21 Experts available now in Live!

Get 1:1 Help Now