473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

HttpWebRequest keepalive

I am trying to automate a series of form posts on a website. This site
requires that my session be kept alive through successive posts (it
basically tracks me by a sessionid, and if I get a new connection each time,
I get a new sessionid).
An HttpWebRequest object has a KeepAlive property that is, by default, set
to true. I have been unsuccessful in finding adequate documentation about
this. Most people seem to not want to keep the connection alive, so they
set the property to false, and is thus, the exact opposite of what I am
looking for.
What I am wondering is how I go about making successive requests with the
same connection? If KeepAlive is set to true, does the object just
automatically reuse a connection to a server if it exists? I cannnot seem
to find a way to "reuse" my webrequest object, and have to create a new one
each time.
What would be the method to create successive Requests/Responses to a server
on the same connection?

Thanks,
-Cliff
Nov 15 '05 #1
1 9281
"Cliff Harris" wrote:
I am trying to automate a series of form posts on a website. This
site requires that my session be kept alive through successive posts
(it basically tracks me by a sessionid, and if I get a new
connection each time, I get a new sessionid).
An HttpWebRequest object has a KeepAlive property that is, by
default, set to true. I have been unsuccessful in finding adequate
documentation about this. Most people seem to not want to keep the
connection alive, so they set the property to false, and is thus,
the exact opposite of what I am looking for.
What I am wondering is how I go about making successive requests
with the same connection? If KeepAlive is set to true, does the
object just automatically reuse a connection to a server if it
exists? I cannnot seem to find a way to "reuse" my webrequest
object, and have to create a new one each time.
What would be the method to create successive Requests/Responses to
a server on the same connection?


Cliff,

sessions have nothing to do with persistent connections (known as "keep-
alive" connections in HTTP 1.0). Keep-alive connections are a mere
performance optimization at TCP level to reduce the overhead of opening
new a TCP connection for each new HTTP request.

For what you want to achieve, you'll need to resubmit the session id you
mentioned with each request. How that can be achieved depends on how
sessions are implemented by the web application -- could be cookies, URL
rewriting, or hidden fields. Remember that HttpWebRequest requires a
CookieContainer instance, otherwise the corresponding HttpWebResponse
will not contain any cookies.

Cheers,
--
Joerg Jooss
jo*********@gmx.net
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ziphyre | last post by:
Hi, I can't send 'Connection: Keep-Alive' property in the second connection of my HttpWebRequest. Suppose: HttpWebRequest hreq = ..... hreq.KeepAlive = true; HttpWebResponse hresp =...
0
by: Peter Qian | last post by:
Hi, I'm working on a windows form based program that can log into a web service (Apache based, https is used for auth). I was able to post the login data and obtain a sessionID. However I'm not...
6
by: VladG | last post by:
The following code being repeated in a loop sends keep-alive at frst iteration only. So I quickly run out of ports (all are in time_wait state) Why? // create the web request to get the remote...
1
by: Paul DeMarco | last post by:
I'm using the HttpWebRequest repeatidly. I have basic authentication, unsafe connection pooling, keepalive, and preauthentication on. Within .NET it clearly reuses the http connections, I can...
0
by: joshblair | last post by:
Hello, I am trying to post XML documents to a third party using the HttpWebRequest. This URL uses HTTPS (SSL) but I don't have a client certificate to deal with. Apparently they are using...
3
by: stoogots2 | last post by:
Hi, I was using the WebClient class (to do some screen scraping) and I was forced to change to the HttpWebRequest/Response because I needed control over the http headers. I am having two problems...
8
by: gerbrandc | last post by:
Hello, I hope somebody has a good explanation for this issue. Okay I'm having troubles with the httpWebRequest method. I need to download reports from a specified server (can't give these...
1
by: twebb72 | last post by:
Scratching my head for a while on this one... This project uses code from "Understanding HttpWebRequest CookieContainer?" post on this site. C#, asp.net 2.0 The following code supplies...
4
by: =?Utf-8?B?SmltIE93ZW4=?= | last post by:
Hi, I've run into a set of errors I don't understand coming back from HttpWebRequest.GetResponse, In one case, null is returned from the request without an Exception and in the other the request...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.