URL checking

Discussion in 'ASP .Net' started by EMW, Jan 21, 2005.

  1. EMW

    EMW Guest

    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
     
    EMW, Jan 21, 2005
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:41f17766$0$44111$...
    > 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
    >
    >
     
    Peter Rilling, Jan 21, 2005
    #2
    1. Advertising

  3. EMW

    MWells Guest

    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" <> wrote in message
    news:#...
    > 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" <> wrote in message
    > news:41f17766$0$44111$...
    > > 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
    > >
    > >

    >
    >
     
    MWells, Jan 22, 2005
    #3
  4. EMW

    shailpatel83

    Joined:
    Jun 11, 2009
    Messages:
    9
    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
     
    shailpatel83, Jan 25, 2010
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob

    checking the url

    Rob, Feb 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,469
    Rick Strahl [MVP]
    Feb 23, 2004
  2. Jon paugh
    Replies:
    1
    Views:
    861
  3. Checking relative url

    , Jun 7, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    596
    Scott Allen
    Jun 7, 2005
  4. Rasheed
    Replies:
    1
    Views:
    673
    Alf P. Steinbach
    Jul 30, 2007
  5. Just D.
    Replies:
    0
    Views:
    499
    Just D.
    Aug 11, 2004
Loading...

Share This Page