Verifying a URL

Discussion in 'ASP .Net' started by julian, Jul 17, 2003.

  1. julian

    julian Guest

    Hi,

    I have situation where I want to use a stylesheet stored
    in one of two possible urls. Basically I need to say if
    the first url doesn't exist, use the second url.

    I can do this by creating a WebRequest and intercepting
    the exception raised by the GetResponse if the first url
    doesn't exisit, but this feels like a hack to me and I was
    hoping there would be some simple way (similar to
    File.Exists) to check whether a url refered to a file that
    was actually there?

    Any help would be appreciated.

    Thanks.
    julian, Jul 17, 2003
    #1
    1. Advertising

  2. julian

    Mario Vargas Guest

    Actually, before I finished reading your post I thought about telling you to
    use the WebRequest class. I think you are on the right track, but you might
    want to consider caching the URL so that it's not done for every request to
    your web form.

    Mario

    "julian" <> wrote in message
    news:087b01c34c61$3c6a3d40$...
    > Hi,
    >
    > I have situation where I want to use a stylesheet stored
    > in one of two possible urls. Basically I need to say if
    > the first url doesn't exist, use the second url.
    >
    > I can do this by creating a WebRequest and intercepting
    > the exception raised by the GetResponse if the first url
    > doesn't exisit, but this feels like a hack to me and I was
    > hoping there would be some simple way (similar to
    > File.Exists) to check whether a url refered to a file that
    > was actually there?
    >
    > Any help would be appreciated.
    >
    > Thanks.
    Mario Vargas, Jul 17, 2003
    #2
    1. Advertising

  3. julian

    julian Guest

    Thanks for the responses. I guess I will leave it the way
    it is then - it certainly works. I just feel a bit
    guilty / lazy to be using Exceptions to handle an expected
    condition (i.e. not an error).


    >-----Original Message-----
    >Hi,
    >
    >I have situation where I want to use a stylesheet stored
    >in one of two possible urls. Basically I need to say if
    >the first url doesn't exist, use the second url.
    >
    >I can do this by creating a WebRequest and intercepting
    >the exception raised by the GetResponse if the first url
    >doesn't exisit, but this feels like a hack to me and I

    was
    >hoping there would be some simple way (similar to
    >File.Exists) to check whether a url refered to a file

    that
    >was actually there?
    >
    >Any help would be appreciated.
    >
    >Thanks.
    >.
    >
    julian, Jul 17, 2003
    #3
  4. julian

    Mario Vargas Guest

    Actually, that's why structured exception handling was created. You catch an
    exception to recover from it. That's how your applications come become
    "smarter." They learn from their mistakes, he he.

    Mario

    "julian" <> wrote in message
    news:00d501c34c75$a38fc9e0$...
    > Thanks for the responses. I guess I will leave it the way
    > it is then - it certainly works. I just feel a bit
    > guilty / lazy to be using Exceptions to handle an expected
    > condition (i.e. not an error).
    >
    >
    > >-----Original Message-----
    > >Hi,
    > >
    > >I have situation where I want to use a stylesheet stored
    > >in one of two possible urls. Basically I need to say if
    > >the first url doesn't exist, use the second url.
    > >
    > >I can do this by creating a WebRequest and intercepting
    > >the exception raised by the GetResponse if the first url
    > >doesn't exisit, but this feels like a hack to me and I

    > was
    > >hoping there would be some simple way (similar to
    > >File.Exists) to check whether a url refered to a file

    > that
    > >was actually there?
    > >
    > >Any help would be appreciated.
    > >
    > >Thanks.
    > >.
    > >
    Mario Vargas, Jul 17, 2003
    #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. Jon paugh
    Replies:
    1
    Views:
    681
  2. Replies:
    1
    Views:
    900
    Fredrik Lundh
    Nov 20, 2006
  3. Just D.
    Replies:
    0
    Views:
    400
    Just D.
    Aug 11, 2004
  4. Pete
    Replies:
    2
    Views:
    78
    Martin Honnen
    Nov 28, 2004
  5. Replies:
    4
    Views:
    335
Loading...

Share This Page