Pinging domain name using asp?

Results 1 to 8 of 8

Thread: Pinging domain name using asp?

  1. #1
    Hameed Bhatti Guest

    Default Pinging domain name using asp?

    I am iterating through about 300 records in a table. One of the fields is a URL (website address) - I want to able to find out if the website is up or if the website is down. If it is down, I will set a flag to 0 in another field in the table so that when users are browsing my portal site they don't see the listings with the flag set to 0 because those are broken links or sites that no longer exist. Can this be done with ASP? If so, please guide me.

  2. #2
    Join Date
    Dec 1969

    Default You need a component... do this. And I *believe* that has such a component available. It might even be free.<BR><BR>Or, of course, you could easily write your own component to do this using VB or Java or C++.<BR><BR>ONE THING THOUGH: Ping is *not* a reliable way of finding out if the Web server is up! Ping uses a different port number than does HTTP, so it goes to a different process on the server machine. You&#039;ll know if the server *machine* is up or not, but you won&#039;t know for sure that the web server is up.<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default Or...

    You could use the code presented at this article on 4Guys:<BR><BR>How to Ping Using ASP <BR><BR><BR>:-)<BR><BR>Happy Programming!

  4. #4
    Join Date
    Dec 1969

    Default Yeah, but that is still a component...

    It just happens that the component in this case is WScript.Shell, right?<BR><BR>Heh! Sorry about that, Scott. I missed that one. <BR><BR>I *would* point out that invoking the shell and using a text file and and and would all be pretty slow! If you are really going to test 300 servers this way, I&#039;d be *real* tempted to use a custom component, instead. Heck, write your own and pass all 300 URLs to it as an array. Let it use multi-threading to do many pings at the same time and get the answer back really fast.<BR><BR>But, still... Is ping really an adequate test? As I noted in my other response?<BR><BR>

  5. #5
    Aquarius Guest

    Default RE: Yeah, but that is still a component...

    Bill said:<BR>But, still... Is ping really an adequate test? As I noted in my other response?<BR><BR>I&#039;m inclined to agree -- you could actually try fetching the page using the XMLHTTP object or some other ASP page-fetch component, like ASPTear (see for some notes on XMLHTTP) and check the result for 404s -- note that this would have the advantage that (a) you&#039;d actually know whether the page was there, rather than just whether the server was up (as Bill W said), and (b) if you&#039;re feeling clever, you could trap 302 Moved Temporarily and other 3xx HTTP response codes and update the database, so your users never ran into broken or moved links.<BR><BR>Incidentally, the whole idea of shelling out to a batch file or some other command process needs careful consideration, if whatever you&#039;re doing is going to get interpreted by CMD.EXE. I invite you to consider what would happen if you&#039;re shelling to a process and somehow the URL in the database was set to " && del c:winnt*.*" ...<BR><BR>Aq.<BR>

  6. #6
    Wolfgang Guest

    Default RE: Yeah, but that is still a component...

    Pinging a server is NOT a reliable test to see whether an URL can be reached, for two reasons: <BR><BR>1) you would only test whether the machine is reachable and have no indication whether the page you are looking for is available<BR>2) many Admins disable the processing of ICMP packets (which are used for pings) on their machines for security reasons (ever tried pinging<BR><BR>just my 2 cents,<BR>Wolfgang

  7. #7
    vilas Guest

    Default RE: Yeah, but that is still a component...


  8. #8
    Dan Taflin Guest

    Default Use XMLHTTP with

    I vote for using XMLHTTP. The nice thing about XMLHTTP is that it&#039;s a standard, Microsoft-supplied component (people like me who let someone else host their websites will appreciate that, because the hosting company won&#039;t usually accept home-grown components).<BR><BR>By using the "HEAD" method (rather than get, post, etc.) you just get back the header, not the whole page, and you can then just pull out the HTTP status code. Anything other than 200 is bad. The following code works:<BR><BR>Dim xobj, Status<BR>Set xobj = Server.CreateObject("MSXML2.XMLHTTP")<BR>xobj.Open "HEAD", "", False<BR>xobj.Send<BR>Status = xobj.status

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts