Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Image does not show up

Image does not show up

Scheduled Pinned Locked Moved ASP.NET
csharphelpasp-netvisual-studiodesign
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NetRocker
    wrote on last edited by
    #1

    Hi, I created a ASP.NET page using C# to display images. The problem how ever is that on my local computer I can see all the images in the Image Box (from the toolbox of VS.NET) but no image is displayed when the application in hosted!! Any help is appreciated. I am going to attach a sample of the code below. Main_load( .....) { System.Web.UI.WebControls.Image _image = new Image(); filenames = Directory.GetFiles(Server.MapPath("./Photos")); _image.ImageUrl = Server.MapPath("./Photos/" + Path.GetFileName(url)); } The images are in the folder called Photos. Thanks, Sandeep

    I 1 Reply Last reply
    0
    • N NetRocker

      Hi, I created a ASP.NET page using C# to display images. The problem how ever is that on my local computer I can see all the images in the Image Box (from the toolbox of VS.NET) but no image is displayed when the application in hosted!! Any help is appreciated. I am going to attach a sample of the code below. Main_load( .....) { System.Web.UI.WebControls.Image _image = new Image(); filenames = Directory.GetFiles(Server.MapPath("./Photos")); _image.ImageUrl = Server.MapPath("./Photos/" + Path.GetFileName(url)); } The images are in the folder called Photos. Thanks, Sandeep

      I Offline
      I Offline
      Ista
      wrote on last edited by
      #2

      you need to use relative file locations. Especially since its hosted by someone else. I guarantee you cant access thier file systen. For instance if all the images are in a folder called images from the web app src="../images/myimage.gif" Nick 1 line of code equals many bugs. So don't write any!!

      N 1 Reply Last reply
      0
      • I Ista

        you need to use relative file locations. Especially since its hosted by someone else. I guarantee you cant access thier file systen. For instance if all the images are in a folder called images from the web app src="../images/myimage.gif" Nick 1 line of code equals many bugs. So don't write any!!

        N Offline
        N Offline
        NetRocker
        wrote on last edited by
        #3

        Thanks Nick. For some reason Server.MapPath did not work. Anyways i just replace it by ./Photos as u mentioned and it worked. Any idea why Server.MapPath didnt work?

        I 1 Reply Last reply
        0
        • N NetRocker

          Thanks Nick. For some reason Server.MapPath did not work. Anyways i just replace it by ./Photos as u mentioned and it worked. Any idea why Server.MapPath didnt work?

          I Offline
          I Offline
          Ista
          wrote on last edited by
          #4

          Thats because the MapPath gets the physical path. On host servers for the company providers, often thier virtual ghost partitions. So, theres not really an actual path to find. So do everything as relative to the Web Root Nick 1 line of code equals many bugs. So don't write any!!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups