Operation has timed out Exception
Dear friends,
I am developing one Windows application under C# (.NET 2003) which uses HttpWebRequest and HttpWebResponse.
I have written the following code in application.
// Code Start
HttpWebRequest HWReq1 = null;
HttpWebResponse HWResp1 = null;
try
{
HWReq1 = (HttpWebRequest) WebRequest.Create("http://www.google.co.in/search?q=India");
HWReq1.Timeout=25000;
HWReq1.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50215)";
HWReq1.AllowAutoRedirect= true;
HWReq1.Method="POST";
HWReq1.ContentType = "text/html";
HWResp1 = (HttpWebResponse)HWReq1.GetResponse();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
// Code End
When I run the above code i get an exception "Operation has timed out"
I have tried with different Timeout property including -1 (infinite) but it doesnt work.
but when i run the same code in .NET 2005 windows application , it runs successfully without any Error.
Can any one help me and tell me that why this is happening ?