Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3544
  • Last Modified:

How to display image in <asp:Image> server control from local path or UNC network path

My web page was displaying images from this path just fine before we changed our domain as a result of our company rebranding:

<asp:Image runat="server" ID="IDPicture" ImageUrl="\\AnyServer\Pics\000000000.jpg" />

I know the path is correct because the image displays in the VS designer just fine.  The only thing that's change is our domain, so the web address went from syep.wf1broward.com/admin.aspx to syep.careersource.com/admin.aspx.

Staff will be scanning images and saving them to either their local C:\ drive or a network share (\\AnyServer) and need to have them immediately displayed in the web application.

ImageUrl="C:\Pics\000000000.jpg" /> doesn't work
ImageUrl="\\AnyServer\Pics\000000000.jpg" /> doesn't work (It did before our rebranding)
Image Url="file:///C:/Pics/000000000.jpg" /> doesn't work

How can I get the images to show if they are stored on the local PC, i.e. "C:\Pics\000000000.jpg"?

Thanks!
0
megnin
Asked:
megnin
  • 7
  • 4
  • 2
  • +1
1 Solution
 
CodeCruiserCommented:
It may be a permissions issue. Make sure the permissions are set on the folder so that it can be accessed by the IIS.
0
 
megninAuthor Commented:
Yeah, I'm just not sure what account to grant permissions to.

From my desktop workstation I opened the remote folder \\AnyServer\Pics and added Read, Read & Execute and List folder contents permissions to NETWORK SERVICE.  I'm not sure if that has to be done ON the server or if there's another account I need to grand permissions to.  ...ASPNET or something maybe?

Since the staff will be offsite, I'll need to have the page display the images from their local hard drive, "C:\IDPictures"
0
 
CodeCruiserCommented:
Well you cannot access images stored on their C drive unless they upload those images.

What account is the website apppool running under? You need to grant permission to that account.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
megninAuthor Commented:
"ApplicationPoolIdentity"... does that sound right?  That's what's listed in Advance Settings under Process Model | Identity.
0
 
CodeCruiserCommented:
Not seen that. It is usually one of the built in accounts like Network Service or can be a specific user account.
0
 
megninAuthor Commented:
Sorry for the late reply; I wasn't in the office on Friday.

It looks like it may just not be possible, or at least practically feasible.  I'm just going to have the staff scan the ID pictures to their local laptops, in this case, and I'll copy the files from each of them into the /images folder of the web site they use for administration.  It would be nice for them to have the images available, from the local hard drive, on the admin site the moment they scan them, but they really only require the images to be available at a later date after initial intake, during an orientation check in later in the year.  By then I'll have copied all the images into the web site /images folder.

I'm going to leave this question open for just a bit to see if anyone offers any good solutions.

Adding an upload function would be a good idea, but I don't want ID images being transferred any more than necessary, so I'll just leave them on the laptop drives for now.
0
 
CodeCruiserCommented:
The problem with leaving images on laptops is the risk of losing those images (laptop stolen, damaged etc).
0
 
megninAuthor Commented:
Yeah, that's the primary concern that my boss and I have discussed.  It looks like it's one of those risks that we have little choice but to accept.

It's still better than the staff's previous method.  They would scan everything onto paper and keep it in large three-ring binders.  ;-)
0
 
Robert SchuttSoftware EngineerCommented:
You say it worked before. Probably the old domain was added to Trusted Sites or Intranet zone in your Internet Explorer Security options. So first thing to try is add the new domain to the same security zone.

I think IE is the only browser that supports this. Remember, even though you use <asp:Image runat="server" .../> this generates an <img src="..."> tag in the html that is handled client-side. If it contains a relative or absolute url the image will be retrieved from the web normally but in this case you are in fact showing a local image so you need to be aware that this can only be seen by the person who has that particular image on his hard-drive (if you use "C:\..."). For a network share that should not be a problem if all users can access it, or maybe it's not a problem at all if users can't see the data entered by others anyway. Using a network share of course also reduces the risk of losing the scans.

Funny thing I just saw FireFox does not show the picture but FireBug does:
screen captureI tested with image url/src: "file://///127.0.0.1/Pics/BSOD.jpg" which is (I think) the official way to point to "\\127.0.0.1\Pics\BSOD.jpg" (but that actually also works in IE). For C:\ it's slightly different (using "file:///C|/...") but then again, as you said it worked before, you probably don't need to change that.
0
 
megninAuthor Commented:
Thank you Robert.  I think you're right about the old domain having been added to the Trusted Sites or Intranet zone.  I forgot about that.  

Yeah, my preference would be to use a network share so that everyone (well, all 2 or 3) can see all of the images, but "local only" would be okay as well.

I'll try again with your suggestions.  It may be later today before I get to it.  It's Monday and I have a dozen concurrent projects going on.  ;-)

Edit:  I had to "Google" that T-Shirt for a closer inspection.  ;-)
0
 
Robert SchuttSoftware EngineerCommented:
Did you ever come to a conclusion on this?
0
 
megninAuthor Commented:
Yeah, I moved all the images to the web server.  Thanks for the follow-up.
0
 
GaryCommented:
I've requested that this question be deleted for the following reason:

The question has either no comments or not enough useful information to be called an "answer".
0
 
megninAuthor Commented:
Thank you for the information.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 7
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now