Problem displaying images..

Discussion in 'ASP.NET / ASP.NET Core' started by jevans, Apr 27, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I am haveing a problem displaying images on my DASP site. I store the graphic files in a subdir \Images and then in code I bind the image controls to the files like this.

    img1.ImageUrl = context.Request.ApplicationPath & "/Images/image1.gif"

    This works fine in my dev environment - but I get the red x on DASP.

    Any help???

    Thanks


    J. Evans
     
  2. Try replacing <u>context.Request.ApplicationPath</u> with <u>Server.MapPath("")</u>.
     
  3. Sory -

    I forgot to mention in the first post that I had tried Server.MapPath also. Both of these approaches work in my dev environment - neither work in the DASP environment. They are not resolving the path to the file location correctly when I show properties on the image control at runtime. Could it be that I need to do some setup on the Images folder with IIS Mgr?? IIS is not one of my strong points.

    J. Evans
     
  4. Can you give the url which is in the html source of your page and also the url which it would need to be ? We might find the answer in here.

    --
    Steurm
    www.steurm.net/steurm
     
  5. Well....

    Actually, to get my site looking somewhat professional, I moved all the graphics file into the home folder and just used:

    img1.ImageUrl = "image1.gif"

    This does work. I have done a complete new version of my website - all new look. This is the one that depends on the subfolders. I can't move it up to production untill I resolve this.

    I'll try and put something in the current production version to demonstrate the issue.

    I noticed on your site that you are using the same stratigy - a subfolder for the images - how are you resolving the path to the image files?

    J. Evans
     
  6. OK.

    Image1.ImageUrl = "pics/2004.jpg";

    This works both on my local machine and on the DASP server.

    Thanks

    Todd Thigpen
    Webmaster
     
  7. I am having the same problem.

    string Path = Server.MapPath("");
    Image1.ImageUrl = Path + "\\pics\\2004.jpg";

    This code works great on my local machine, but not on the DASP Site.

    I need to organize my images in directories. The solution to put them in my root is not acceptable.

    Todd Thigpen
    Webmaster
     
  8. Bruce

    Bruce DiscountASP.NET Staff

    server.mappath gives your the physical path (e:\web\something\htdocs) to the file.

    ImageURL is looking for the URL, eg. http://www.yourdomain.com/pics/2004.jpg

    It will work on your local machine because the physical path can also bring up the image.


    quote:Originally posted by Packman

    I am having the same problem.

    string Path = Server.MapPath("");
    Image1.ImageUrl = Path + "\\pics\\2004.jpg";

    This code works great on my local machine, but not on the DASP Site.

    I need to organize my images in directories. The solution to put them in my root is not acceptable.

    Todd Thigpen
    Webmaster
    </blockquote id="quote"></font id="quote">
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page