By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,188 Members | 1,610 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,188 IT Pros & Developers. It's quick & easy.

URL checking

P: n/a
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
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

"EMW" <so*****@MikroZoft.com> wrote in message
news:41**********************@dreader2.news.tiscal i.nl...
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

Nov 19 '05 #2

P: n/a
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

"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:#W**************@TK2MSFTNGP11.phx.gbl...
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.

"EMW" <so*****@MikroZoft.com> wrote in message
news:41**********************@dreader2.news.tiscal i.nl...
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


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.