first, you're using the wrong classes. You need to use
HttpWebRequest and HttpWebResponse. Example:
HttpWebRequest req = WebRequest.Create(sAddressTime);
HttpWebResponse result = req.GetResponse();
The HttpWebRequest and HttpWebResponse classes are derived from WebRequest
and WebResponse, but more specific to Http. In fact, when you use an HTTP
URL with WebRequest.Create, you get an HttpWebRequest back, and when you
send an HttpWebRequest, you get an HttpWebResponse back.
try this....
One of the first things you might want to do is check the Response. Here's a
little function I wrote that parses a string containing Response information
from an HttpWebResponse:
/// <summary>
/// Retrieves Response Information from the Response
/// </summary>
/// <param name="Response">Formatted string containing Response
Information</param>
/// <returns>Formatted string containing Response Information</returns>
public static string GetResponseInfo(HttpWebResponse Response)
{
try
{
StringBuilder sb = new StringBuilder(Response.ResponseUri.ToString());
sb.Append(Environment.NewLine + "Status Code: " +
Response.StatusCode.ToString());
sb.Append(Environment.NewLine + "Status Description: " +
Response.StatusDescription);
sb.Append(Environment.NewLine + "Content Length: " +
Response.ContentLength.ToString());
return sb.ToString();
}
catch (Exception ex)
{
//whatever you want to do to handle the exception
}
}