I have an ASP.Net 3.5 web application (C #) where I need to programmatically check if another of our sites is working (not ASP.Net). I currently have a method with the following code that checks the StatusCode 200. The problem I am facing is that the IIS7 popup page that appears returns a status code of 200 and I don’t see anything else in the response object. which will allow me to check the page that we expect is actually displayed. I would like to avoid getting a response and using StreamReader only to find the div on the page to check its validity (if possible), as they do (similarly) in this .
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlToCheck); request.AllowAutoRedirect = true; HttpWebResponse response; try { response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { return true; } return false; } catch (Exception) { return false; }
Any help is greatly appreciated.
source share