[Mono-aspnet-list] HttpWebRequest --> System.Net.WebException: The request timed out

chin kaimerachin at gmail.com
Fri Dec 21 08:35:08 UTC 2012


Hi guys, 

First, Merry Christmas to you guys. :)

I need some help on this, I'm in the middle of migrating my .NET codes to
Mono, but i keep getting "The request time out" when i'm running the
following code.

I've gone through stackoverflow, google and could get a clear answer.
http://stackoverflow.com/search?q=%5Bmono%5D+HttpWebRequest
<http://stackoverflow.com/search?q=%5Bmono%5D+HttpWebRequest>  

The following code is running perfectly in .NET codes, but keep throwing
time out exception.


*My code*
string postData = "{\"name\": \"My Name\",\"age\": \"234\"}";
HttpWebRequest webRequest = HttpWebRequest.Create(url) as HttpWebRequest;

webRequest.Timeout = 120 * 60000; //mins * milisec
webRequest.ReadWriteTimeout = 120 * 60000; //mins * milisec
webRequest.Method = WebRequestMethods.Http.Post;
webRequest.ContentLength = postData.Length;
webRequest.ContentType = "application/x-www-form-urlencoded";

using (StreamWriter writer = new
StreamWriter(webRequest.GetRequestStream()))
{
	writer.Write(postData);
	writer.Flush();
}            
				
using (HttpWebResponse resp = webRequest.GetResponse() as HttpWebResponse)
{
// do something
}

Thank you in advance. :)



--
View this message in context: http://mono.1490590.n4.nabble.com/HttpWebRequest-System-Net-WebException-The-request-timed-out-tp4657849.html
Sent from the Mono - ASP.NET mailing list archive at Nabble.com.


More information about the Mono-aspnet-list mailing list