检查另一个Web服务器是否正在侦听asp

时间:2008-09-18 09:34:00

标签: asp-classic

我正在使用Microsoft.XMLHTTP从旧的ASP / VBScript站点从另一台服务器获取一些信息。但是其他服务器经常重启,所以我想在尝试从中提取信息之前检查它是否正常运行(或者通过其他方式检测问题来避免我的页面提供HTTP 500)。

如何使用ASP执行此操作?

2 个答案:

答案 0 :(得分:2)

您可以尝试ping服务器并检查响应。 看一下这个article

答案 1 :(得分:1)

您需要做的就是让代码继续出错,然后发布到其他服务器并从帖子中读取状态。像这样:

PostURL = homelink & "CustID.aspx?SearchFlag=PO"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.3.0")

错误重启

xmlhttp.open "POST", PostURL, false
xmlhttp.send ""

status = xmlhttp.status

if err.number <> 0 or status <> 200 then
    if status = 404 then
        Response.Write "ERROR: Page does not exist (404).<BR><BR>"
    elseif status >= 401 and status < 402 then
        Response.Write "ERROR: Access denied (401).<BR><BR>"
    elseif status >= 500 and status <= 600 then
        Response.Write "ERROR: 500 Internal Server Error on remote site.<BR><BR>"
    else
        Response.write "ERROR: Server is down or does not exist.<BR><BR>"
    end if
else
    'Response.Write "Server is up and URL is available.<BR><BR>"
    getcustomXML = xmlhttp.responseText
end if
set xmlhttp = nothing
相关问题