Solved

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

Posted on 2014-02-13
15
3,239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

635 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