Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?


2 Answers

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.

like image 149
Noldorin Avatar answered Dec 08 '25 04:12

Noldorin


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.

like image 37
Noldorin Avatar answered Dec 08 '25 05:12

Noldorin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!