URL, If Not Exists...

S

Steve Schroeder

Any way I can determine if a particular URL is valid before I assign it to
an ImageUrl property?

I'm digging in the help now, but if someone knows, help would be greatly
appreciated, thanks :)

Steve
 
M

Marina

Don't think there is an easy way to do it. I think you would actually have
to issue and HTTP request to that URL, and see what you get back. You would
have to account for connection errors, possibilities of getting a file not
found, or access denied error, etc. It would also be sort of time consuming
and cubersome, if you have lots of images.
 
S

Steve Schroeder

Well, the files are stored locally on an intranet, the whole project is
intranet based actually. The images are employee photos, and some have a
photo and some don't. So I was hoping to interject a 'Photo Not Available'
photo in the instace one didn't exist. Any ideas?

Thanks,

Steve
 
M

Marina

If it's just on the intranet, then you could just do a
File.Exists(imageLocation), to see if the image exists at a particular
location.
 
A

Aidy

If you have access to the file system the images are stored on then check
via System.IO. If not then request the URL through code and see if you get
a 404 or not.
 
S

Steve Schroeder

Aidy, Marina,

Thanks. Now I just have reconstruct the file path from URL to disk path,
then validate it.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,610
Members
45,255
Latest member
TopCryptoTwitterChannels

Latest Threads

Top