Thursday, April 28, 2011

Request a 2nd url with the same HttpWebRequest obj

I want to do something like this

{
    HttpWebRequest WebRequestObject = (HttpWebRequest)HttpWebRequest.Create("http://google.com");
    WebRequestObject.KeepAlive = true;
    //do stuff
    WebRequestObject.Something("http://www.google.com/intl/en_ALL/images/logo.gif");
    //more here
}

How do i keep the connection alive and go to multiple urls using that same alive connection?

From stackoverflow
  • You simply use another HttpWebRequest object and provided that you set KeepAlive to true in both cases the internal HTTP connection manager in the .NET Framework should handle things for you. See the MSDN documentation for the KeepAlive property for more info on this.

    Noldorin : Also, if you want to confirm this, just use a packet analyser such as Wireshark to monitor your HTTP traffic.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.