Web based photo gallery using SQL

In an entry last November I noted that I was enjoying ADO.NET and ASP.NET so much that I’d have another go at writing a web based photo gallery app that stored the images in SQL. I had most of it working by the end of the year, but my cat ski trip to Canada gave me the perfect excuse to actually work on it. It’ now at the point where I can actually use it.


I know that storing images in SQL Server vs. the file system has performance issues, but I don’t plan on using this for anything but my own personal websites and I’ve structured things so it will be easy for me to change the database schema to have the images live in the file system without having to change the app. In anycase, because I did it using SQL I got to learn about HttpHandlers and URL re-writing in ASP.NET. Way cool stuff.


So go to http://www.kindel.com/revelstoke/2004 and click on “Photos”. You’ll be taken to an ugly photo gallery (I’m no web designer). Note if you click on a thumbnail you get a medium sized image, and if you click on that, you get the full sized image. The URL to the full sized image is just a “.JPG” URL. But the file was actually served up out of the database. For fun append “?size=med” to one of these URLs and load it. Cool, eh?


URL re-writing allows the webserver to receive  request for a particular url (say foo.jpg) and “re-write” it before the app server (ASP.NET in my case) processes it (say to viewimage.aspx?name=foo.jpg). I found a great URL re-writing example on 15seconds.com at http://www.15seconds.com/issue/030522.htm. I had to modify Rewrite.NET to suit my needs, but it’s a great sample. (Oh, I also had to re-learn regular expressions which is cool).


Fun stuff.

© Charlie Kindel. All Rights Reserved.

2 comments


  1. http://

    Hello,

    I am new at this, but also trying to create a way for people to upload images from their digital camera or scan photos onto a database for viewing online.

    You wrote "I know that storing images in SQL Server vs. the file system has performance issues" Since i am new at this could you explain to me why? Also what is file system?

    15seconds.com was helpful.

    Thanks,

    ML

  2. Greetings from Malaga (Spain). Antonio 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *