【问题标题】:Checking if another web server is listening from asp检查另一个 Web 服务器是否正在侦听 asp
【发布时间】:2008-09-18 09:34:00
【问题描述】:

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

如何使用 ASP 做到这一点?

【问题讨论】:

    标签: asp-classic


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

      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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-04-07
        • 2015-08-28
        • 2011-05-14
        • 2020-05-25
        • 2014-04-02
        • 2011-02-19
        • 2011-08-15
        相关资源
        最近更新 更多