本文在C#中使用XMLHTTP对网页的可访问性进行了演示:
private bool checkWeb() { string url = "http://XXXXX"; XMLHTTP http = new XMLHTTP(); try { http.open("GET ", url, false, null, null); http.send(null); int iStatus = http.status; //如果取得的网页状态不正确, 就是出问题了 if (iStatus == 200) { isOn = " is working"; return true; } else { isOn = " is not working"; return false; } } catch (Exception ex) { } return false; }