HttpWebRequest Timeout

HttpWebRequest Timeout

You can set time to live on for connection to the server using HttpWebRequest object Timeout property
as shown in below code.

using  System.Net;

 protected void Button1_Click(object sender, EventArgs e)

   HttpWebRequest request = (HttpWebRequest)WebRequest.Create(; 

  // setting up connection with web and posting

  request.Timeout = 15 * 1000;  

  // This is timout in millisecond 1 second = 1000 milliseconds 
  request.ContentType = "application/x-www-form-urlencoded";  

//   you can set content type of request to  application/x-www-form-urlencoded 

  HttpWebResponse response = (HttpWebResponse)request.GetResponse();

// Returns httpwebresponse StreamReader reader = new StreamReader(response.GetResponseStream());




httpwebrequest web proxyHttpWebRequest Post Session TimeoutHttpWebRequest and yahooHow to use HttpWebRequest and HttpWebResponse.HttpWebRequestc# port process monitor server c# send SMS (Text)Where is my IP location


My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.

I'm Satalaj.