app_data is a protected folder, that users can not access directly. if your
users upload their images this is the correct folder, because any other would
force a recompile of the site (unless the image folder is in a different
vdir).
you just want an image display page. google this group for example code to
display an image with an aspx page (usually from a database, but filesystem
is the same).
-- bruce (sqlwork.com)
> Now I'm finding info out there where other people have had similar problems
> (http://forums.asp.net/p/1096436/2129776.aspx) and that you're not supposed
> to store images in the App_Data folder. Is this correct?
>
> Keith
Keith G Hicks - 13 Mar 2008 14:57 GMT
I have no problem displaying images on an aspx page. That's easy. However,
every time I search for how to do it from the App_Data folder I get things
like this:
http://benfulton.net/blog/2005/11/no-images-allowed-in-appdata-folder.html &
http://forums.asp.net/p/1223850/2191284.aspx (quote from the 2nd link:
"First thing i observed is that you are storing your Image files under
App_Data folder which is not a good Idea.. App_Data folder can only be
contains data such as .mdf files and so on.")
I'm looking for either confirmation that this is true or some very specific
direction on how to make it work. If what I reference above IS true then I'm
looking for advice on where to put image folders. Is it ok to just have them
off the root? Should they be subfolders of the main images folder? Again,
I'm looking for specific examples and/or code and advice. Bottom line is
there seems to be conflicting info out there. Some of you say that uploads
need to go in App_Data because it won't force a recompile but most everyone
else confirms my problem that images CANNOT be dealt with by asp.net if they
are placed in the App_Data folder.
Keith
ShaneLM - 13 Mar 2008 15:57 GMT
I think Bruce was suggesting you create a page that serves the image
from the app_data folder. Since that folder is protected, you won't be
able to load your images by accessing it directly. But, if you create
a page that will load the image from the app_data folder, send the
correct headers to make it an image instead of a page, and then write
the image data out, it may work. For example "showImage.aspx?
image=hello.jpg" would be in your image tag.
If this is not what Bruce was suggesting, then forgive me - i'm a
newbie too.
It seems to me like it might be more hassle than convenience storing
the images there. Perhaps you should try a different folder and set up
permissions accordingly.
Good luck!