I wrote a simple console application to check and see if my site it up by check a link that always work. The problem was it went down the other day and it didnt notify me, it had the error:
system.net.webexception the operation has timed out at system.net.httpwebrequest.getresponse
I set the timeout as 15000 milliseconds so 15 seconds. I look at firebug when it was requesting and it said the request was aborted, I didnt get to see the status code. But I am wondering why am i getting this expection when I set the timeout?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            WebRequest request = WebRequest.Create("http://MYSITE.com/A/P/LIB/22?encoding=UTF-8&b=100");
            request.Timeout = 15000;
            SmtpClient mailserver = null;
            try
            {
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                if (response == null || response.StatusCode != HttpStatusCode.OK)
                {
                    MailMessage contactMsg = new MailMessage();
                    contactMsg.To.Add(new MailAddress("[email protected]"));
                    contactMsg.From = new MailAddress("[email protected]");
                    contactMsg.Subject = "Site is not responding!";
                    contactMsg.IsBodyHtml = true;
                    contactMsg.Body = "<html><body><h1>The Site is not responding</h1> " +
                        "Please check the server. <br /><br />Thank You</body></html>";
                    mailserver = new SmtpClient("smtp.mysite.com", 25);
                    //Setup email message
                    try
                    {
                        mailserver.Send(contactMsg);
                        mailserver.Dispose();
                    }
                    catch (Exception exc)
                    {
                        Console.WriteLine(exc.ToString());
                        mailserver.Dispose();
                    }
                    Console.WriteLine("Site is Down!");
                }
                else
                {
                    Console.WriteLine("Site is Up!");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                mailserver.Dispose();
            }
        }
    }
}