Link checker in ASP

Discussion in 'ASP General' started by Gabriella, Oct 13, 2007.

  1. Gabriella

    Gabriella Guest

    Gabriella, Oct 13, 2007
    #1
    1. Advertising

  2. Gabriella

    Evertjan. Guest

    Gabriella wrote on 13 okt 2007 in
    microsoft.public.inetserver.asp.general:

    > I need to verify the exact link, just as
    > http://validator.w3.org/checklink performs the validation -
    > e.g.: if a user inserts http://www.exampleURL.com, i'd like to verify
    > whether it's
    > http://www.exampleURL.com OR
    > http://exampleURL.com OR
    > http://www.exampleURL.com/home.asp


    All three could be valid, and some could be out temporarily.

    Server.XMLhttp requesing the headers for a status = 200 answer should do
    the trick.

    <http://classicasp.aspfaq.com/general/how-do-i-read-the-contents-of-a-
    remote-web-page.html>

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Oct 13, 2007
    #2
    1. Advertising

  3. Gabriella

    Gabriella Guest

    Hi,
    I understand that all three URLs are possible, but I want to know
    WHICH ONE is being used by the webserver.
    If you look at http://www.rsizr.com you will see they redirect you to
    http://rsizr.com - that's what I'd like to know!
    That's what http://validator.w3.org/checklink gives you.
    Server.XMLhttpRequest only tells you, according to the status number,
    whether this URL is broken or valid. Not good enough.
    I need to know which exact URL is being used.

    Thanks, Gabi.
     
    Gabriella, Oct 14, 2007
    #3
  4. "Gabriella" <> wrote in message
    news:...
    > Hi,
    > I understand that all three URLs are possible, but I want to know
    > WHICH ONE is being used by the webserver.
    > If you look at http://www.rsizr.com you will see they redirect you to
    > http://rsizr.com - that's what I'd like to know!
    > That's what http://validator.w3.org/checklink gives you.
    > Server.XMLhttpRequest only tells you, according to the status number,
    > whether this URL is broken or valid. Not good enough.
    > I need to know which exact URL is being used.
    >


    I'm not sure what Server.XMLhttpRequest is but I'll assume we are actually
    talking about MSXML2.ServerXMLHTTP.3.0.

    The site you give as an example is responding with a 301 Moved Permanetly
    status and carries the header Location: http://rsizr.com.

    ServerXMLHTTP will internally follow this redirection and will return
    normally with a 200 response. The problem is that there is no way to
    determine the final URL used internally to complete the request with MSXML3.
    MSXML6 does provide an option to discover this.

    The best and most compatible way is to use the underlying WinHTTP component
    which on Win2000 SP2 or higher is present without additional installs:-

    Function FinalURL(rsURL)

    Dim oWinHTTP
    Const WinHttpRequestOption_URL = 1

    Set oWinHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")

    oWinHTTP.Open "HEAD", rsURL, False
    oWinHTTP.Send

    FinalURL = oWinHttp.Option(WinHttpRequestOption_URL)

    End Function

    sFinalURL = FinalURL("http://www.rsizr.com/")

    You should note however that some sites still rely on HTML meta tags to
    proform a similar function. In those cases this technique isn't going to
    help.


    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Oct 14, 2007
    #4
  5. Gabriella

    Gabriella Guest

    Thanks Anthony, I've tried it and I get the following error:
    "A connection with the server could not be established" right after
    calling FinalURL method in line:
    sFinalURL = FinalURL("http://www.rsizr.com/")
    the error is displayed will every URL I try...
    Any ideas why?
    Gabi.
     
    Gabriella, Oct 15, 2007
    #5
  6. "Gabriella" <> wrote in message
    news:...
    > Thanks Anthony, I've tried it and I get the following error:
    > "A connection with the server could not be established" right after
    > calling FinalURL method in line:
    > sFinalURL = FinalURL("http://www.rsizr.com/")
    > the error is displayed will every URL I try...
    > Any ideas why?


    If you logon to the server as an interactive session can you access the site
    using IE?
    If so, in IE internet settings is a proxy server configured?


    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Oct 15, 2007
    #6
  7. Gabriella

    Gabriella Guest

    Hi, I tried it on shared hosting web server, and it seems like they
    blocked the methods
    oWinHTTP.Open "HEAD", rsURL, False
    oWinHTTP.Send
    also using the same methods on MSXML2.ServerXMLHTTP.3.0. returns the
    same error.
    On the other hand, when trying it on my private web server - it works!
    So THANKS!
     
    Gabriella, Oct 16, 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. Spartanicus
    Replies:
    2
    Views:
    970
    brucie
    May 25, 2004
  2. Fred Atkinson

    Link Checker

    Fred Atkinson, Jun 9, 2005, in forum: HTML
    Replies:
    14
    Views:
    849
    data64
    Jun 12, 2005
  3. Luigi Donatello Asero

    Link checker

    Luigi Donatello Asero, Jan 6, 2006, in forum: HTML
    Replies:
    6
    Views:
    413
    Jonathan N. Little
    Jan 6, 2006
  4. Pager O Rama

    MSN BLOCK CHECKER-MSN STATUS CHECKER-MSN PROBLEMS

    Pager O Rama, Apr 4, 2006, in forum: ASP General
    Replies:
    0
    Views:
    248
    Pager O Rama
    Apr 4, 2006
  5. Jacob Grover
    Replies:
    5
    Views:
    317
    Jacob Grover
    Jul 18, 2008
Loading...

Share This Page