Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

image url problems with subfolders

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Keith G Hicks - 12 Mar 2008 19:51 GMT
I had the following on a page:

<asp:Image runat="server" ID="imgGradLarge" ImageUrl='<%# "ClassmatePics/" &
Eval("GradPhotoFileName") %>'></asp:Image>

The folder "ClassmatePics" was off my site's root. This was working fine.

Some people made recommendations to move folders like this (where users can
upload images) to the App_Data folder so I did that as follows:

C:\Inetpub\wwwroot\Website1\App_Data\ClassmatePics

Of cousre I changed all my code in the images to account for the change as
follows (sevearl ways shown below)

<asp:Image runat="server" ID="imgGradLarge" ImageUrl='<%#
"~/App_Data/ClassmatePics/" & Eval("GradPhotoFileName") %>'></asp:Image>

<asp:Image runat="server" ID="imgGradLarge" ImageUrl='<%#
"App_Data/ClassmatePics/" & Eval("GradPhotoFileName") %>'></asp:Image>

<asp:Image runat="server" ID="imgGradLarge" ImageUrl='<%#
"Website1/App_Data/ClassmatePics/" & Eval("GradPhotoFileName")
%>'></asp:Image>

<asp:Image runat="server" ID="imgGradLarge" ImageUrl='<%#
"/Website1/App_Data/ClassmatePics/" & Eval("GradPhotoFileName")
%>'></asp:Image>

None of the above work at all. No image shows up. The images are in the
folder they're supposed to be in. The folders have read privileges. I don't
get any errors. I just get blank images where before they showed up
correctly. The whole url path thing is goign to be the death of me. It
doesn't seem consistent. Not sure what to do here to get this right. Hope
someone can help.

Thanks,

Keith
Keith G Hicks - 12 Mar 2008 20:04 GMT
When I put an asp image control on a blank page and manually link it to one
of the images in the ClassmatePics folder in the design I can see the image
in design but if I run the app, it doesn't show up on the page (no errors,
just no picture). If I change it to a url of something that's in a folder
rigth off the root (like my Website1/images folder) it does show up in
runtime.

Keith
Keith G Hicks - 12 Mar 2008 20:16 GMT
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
bruce barker - 12 Mar 2008 21:51 GMT
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!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.