URL Validity

Discussion in 'ASP .Net' started by Luke Davis, Sep 18, 2007.

  1. Luke Davis

    Luke Davis Guest

    Is there an easy method that takes a URL string and checks if it is valid?



    Luke
    Luke Davis, Sep 18, 2007
    #1
    1. Advertising

  2. Robbe Morris - [MVP] C#, Sep 18, 2007
    #2
    1. Advertising

  3. You can Regex the string, but something like

    http://www.thisisafakesite.com/default.aspx

    would be seen as valid, as it is correctly formed. You would have to
    actually issue a request to the server and check the return code to
    determine if it was a real site.

    --
    Gregory A. Beamer
    MVP, MCP: +I, SE, SD, DBA

    *************************************************
    | Think outside the box!
    |
    *************************************************
    "Luke Davis" <> wrote in message
    news:eO3CLTj%...
    > Is there an easy method that takes a URL string and checks if it is valid?
    >
    >
    >
    > Luke
    >
    Cowboy \(Gregory A. Beamer\), Sep 18, 2007
    #3
  4. Luke Davis

    Luke Davis Guest

    Invalid as in a 404 error or if it's an image it will come back with a red
    "x". There be nothing at the domain. So if I passed http://google.com/
    it would come back true, but if I passed http://asfsaf3985r2934.com it will
    come back false.


    "Robbe Morris - [MVP] C#" <> wrote in message
    news:uPNCpWj%...
    > What would you consider "invalid"?
    >
    > --
    > Robbe Morris [Microsoft MVP - Visual C#]
    > .NET PropertyGrid Control - ListBox, ComboBox, and Custom Classes
    > http://www.eggheadcafe.com/tutorial...af-5cd3abe27a75/net-propertygrid-control.aspx
    >
    >
    >
    >
    > "Luke Davis" <> wrote in message
    > news:eO3CLTj%...
    >> Is there an easy method that takes a URL string and checks if it is
    >> valid?
    >>
    >>
    >>
    >> Luke
    >>

    >
    Luke Davis, Sep 18, 2007
    #4
  5. HttpWebRequest and HttpWebResponse

    There are tons of samples for these two classes.

    --
    Robbe Morris [Microsoft MVP - Visual C#]
    ..NET PropertyGrid Control - ListBox, ComboBox, and Custom Classes
    http://www.eggheadcafe.com/tutorial...af-5cd3abe27a75/net-propertygrid-control.aspx




    "Luke Davis" <> wrote in message
    news:eKH4s7j%...
    > Invalid as in a 404 error or if it's an image it will come back with a red
    > "x". There be nothing at the domain. So if I passed
    > http://google.com/ it would come back true, but if I passed
    > http://asfsaf3985r2934.com it will come back false.
    >
    >
    > "Robbe Morris - [MVP] C#" <> wrote in message
    > news:uPNCpWj%...
    >> What would you consider "invalid"?
    >>
    >> --
    >> Robbe Morris [Microsoft MVP - Visual C#]
    >> .NET PropertyGrid Control - ListBox, ComboBox, and Custom Classes
    >> http://www.eggheadcafe.com/tutorial...af-5cd3abe27a75/net-propertygrid-control.aspx
    >>
    >>
    >>
    >>
    >> "Luke Davis" <> wrote in message
    >> news:eO3CLTj%...
    >>> Is there an easy method that takes a URL string and checks if it is
    >>> valid?
    >>>
    >>>
    >>>
    >>> Luke
    >>>

    >>

    >
    >
    Robbe Morris - [MVP] C#, Sep 18, 2007
    #5
  6. Luke Davis

    Donn Felker Guest

    Donn Felker, Sep 19, 2007
    #6
  7. Hello Cowboy (Gregory A. Beamer),

    > You can Regex the string, but something like
    >
    > http://www.thisisafakesite.com/default.aspx
    >
    > would be seen as valid, as it is correctly formed. You would have to
    > actually issue a request to the server and check the return code to
    > determine if it was a real site.
    >
    > *************************************************
    > | Think outside the box!
    > |
    > *************************************************
    > "Luke Davis" <> wrote in message
    > news:eO3CLTj%...
    >> Is there an easy method that takes a URL string and checks if it is
    >> valid?
    >>
    >> Luke
    >>


    You could always pass it to the URI class and see what happens. My guess
    is that it will choke on incorrectly formatted URI's.

    --
    Jesse Houwing
    jesse.houwing at sogeti.n
    Jesse Houwing, Sep 19, 2007
    #7
    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. Martin Burger
    Replies:
    3
    Views:
    551
    Roland
    Jun 30, 2005
  2. Zhou Lei

    XML 2 XHTML validity...

    Zhou Lei, Mar 3, 2005, in forum: XML
    Replies:
    2
    Views:
    456
    Zhou Lei
    Mar 5, 2005
  3. Jimmy zhang

    comment on the validity of xpath

    Jimmy zhang, Jul 26, 2005, in forum: XML
    Replies:
    1
    Views:
    328
  4. WT
    Replies:
    4
    Views:
    1,683
    Steven Cheng[MSFT]
    Apr 28, 2006
  5. sendhil

    Validity oF Webservice URL

    sendhil, Dec 6, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    105
    sendhil
    Dec 6, 2003
Loading...

Share This Page