Hi
I need to write a simple WinForms apps that can be fired to test if a website is still alive and that that website is able to read from a database.
I am using the whole "(HttpWebResponse)myHttpWebRequest.GetResponse()" thing in c# to test whether the site is alive, but I am at a lose for how to get a test page in my website to write something to the "Response" to indicate that it was able to test it's own connectivity to the database.
Here is the sample code for my Winforms side (ripped from the MSDN):
private void CheckUrl() { try { HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://www.google.com"); HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); myHttpWebResponse.Close(); label1.Text = myHttpWebRequest.Address.AbsoluteUri; } catch (WebException e) { label1.Text = "This program is expected to throw WebException on successful run." + "\n\nException Message :" + e.Message; if (e.Status == WebExceptionStatus.ProtocolError) { label1.Text = String.Format("Status Code : {0}", ((HttpWebResponse)e.Response).StatusCode); label2.Text =String.Format("Status Description : {0}", ((HttpWebResponse)e.Response).StatusDescription); } } catch (Exception e) { label1.Text = e.Message; } }
I was hoping for some help on the webform side of things to return to the above code.
Thanks for any help that you folks can provide.
- Richard