URL checking

E

EMW

Hi,

My ASPX (vb.NET) page needs to check an URL.
if it exists then it shows the picture (url is to that picture)
if is doesn't exist, it must show another picture.

but the question is how do I know wheater the URL is valid?

I use a Image webcontrol and that doesn't let me know the picture cannot be
found, it just shows the red x.

rg.
Eric
 
P

Peter Rilling

If these images are locale to your machine, you could probably just use the
File.Exist method to determine if that file exists. If these are remote
images, then you will have to use the HttpWebRequest/HttpWebResponse to try
to download the image. If the response is something like a 404, then you
can swap in your substitute image.
 
M

MWells

Using Peter's technique, you could also make a nice site-wide solution using
an HttpModule (or an HttpHandler). There, you would determine if the file
is an image request (.jpg, .jpeg, .gif, .png, .bmp, etc.), and use
System.IO.File.Exist () to determine whether the file is real. If not, you
can Rewrite the Url to point at your placeholder file.

An alternate possibility is to just database the list of photos, and check
there first.

/// M
 
Joined
Jun 11, 2009
Messages
9
Reaction score
0
I found easy solution to check whether image exists on remote url without writing any server side code.

Here is solution that works

shailkpatel.blogspot . com/2009/10/check-whether-image-exists-on-remote. html
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top