views:

205

answers:

1

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?

+3  A: 

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.
Noldorin