Solved

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

Posted on 2014-02-13
15
2,794 Views
Last Modified: 2014-10-20
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
Comment
Question by:megnin
  • 7
  • 4
  • 2
  • +1
15 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39857486
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
 
LVL 1

Author Comment

by:megnin
ID: 39857541
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39857560
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 1

Author Comment

by:megnin
ID: 39857570
"ApplicationPoolIdentity"... does that sound right?  That's what's listed in Advance Settings under Process Model | Identity.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39857606
Not seen that. It is usually one of the built in accounts like Network Service or can be a specific user account.
0
 
LVL 1

Author Comment

by:megnin
ID: 39864588
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39864736
The problem with leaving images on laptops is the risk of losing those images (laptop stolen, damaged etc).
0
 
LVL 1

Author Comment

by:megnin
ID: 39864747
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
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39864909
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
 
LVL 1

Author Comment

by:megnin
ID: 39865029
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
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 40294353
Did you ever come to a conclusion on this?
0
 
LVL 1

Author Comment

by:megnin
ID: 40298371
Yeah, I moved all the images to the web server.  Thanks for the follow-up.
0
 
LVL 58

Expert Comment

by:Gary
ID: 40392331
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
 
LVL 1

Author Closing Comment

by:megnin
ID: 40392332
Thank you for the information.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question