views:

122

answers:

3

Hi all,

I'm developing an intranet webapp in asp.net that has a requirement for storing user profile images.

@edit: The webapp should be running in two different web servers at the same time.

My question is, what would be the best approach? Saving the photo with the profile (I'm using the SqlProfileProvider) or upload it to the file system and just save the link in the profile?

I understand the performance difference from one operation to the other, but my intranet would be used by a few hundred users and I very much like to store all data into a single place (makes backing up data easier for instance).

Assuming data I would store into the database, there are two other questions:

a) what type should I use for saving the photos? byte[]???

b) should I create a handler to display the image, or is there an easier approach?

A: 

Backups should include your web site folders anyway, so I see no clear advantage to not using the file system and IIS for what it is intended to do--store and serve files.

Why go through the trouble of abstracting a file system, complete with all the wire traffic between IIS and MSSQL, code overhead, etc. just to avoid backing up a folder?

richardtallent
I forgot to mention but the webapp is running in 2 web servers.
pablo
+2  A: 

The only reason to think about DB storage would be in a web farm scenario. If you just have one web server it is much faster and easier to use the file system and just store the image path in the profile.

Rob West
I forgot to mention but the webapp is running in 2 web servers.
pablo
+1  A: 

I'm currently using an Image field in my database to store images, however, looking at the warning attached to this documentation, I guess I should move to a VarBinary.

I'm then using an HttpHandler to serve the images as requested (although the latest version of my site also has an MVC file action handler on the images Controller that does the same thing).

An example of my handler can be seen in this answer:

How to know which Image has been requested.

Zhaph - Ben Duguid