Solved

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

Posted on 2014-02-13
15
2,591 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

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

Expert Comment

by:CodeCruiser
Comment Utility
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
Comment Utility
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
Comment Utility
The problem with leaving images on laptops is the risk of losing those images (laptop stolen, damaged etc).
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 1

Author Comment

by:megnin
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Did you ever come to a conclusion on this?
0
 
LVL 1

Author Comment

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

Expert Comment

by:Gary
Comment Utility
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
Comment Utility
Thank you for the information.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now