我正在使用 Microsoft.XMLHTTP 从旧的 ASP/VBScript 站点的另一台服务器获取一些信息。但是该其他服务器经常重新启动,因此我想在尝试从中提取信息之前检查它是否已启动并运行(或通过以其他方式检测问题来避免我的页面提供 HTTP 500)。
我怎样才能用 ASP 做到这一点?
我正在使用 Microsoft.XMLHTTP 从旧的 ASP/VBScript 站点的另一台服务器获取一些信息。但是该其他服务器经常重新启动,因此我想在尝试从中提取信息之前检查它是否已启动并运行(或通过以其他方式检测问题来避免我的页面提供 HTTP 500)。
我怎样才能用 ASP 做到这一点?
您可以尝试对服务器进行 ping 操作并检查响应。看看这篇文章。
您需要做的就是让代码继续出错,然后发布到另一台服务器并从帖子中读取状态。像这样的东西:
PostURL = homelink & "CustID.aspx?SearchFlag=PO"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.3.0")
错误继续下一步
xmlhttp.open "POST", PostURL, false
xmlhttp.send ""
状态 = 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