Using Cookies

G

Giulio Petrucci

Hi there,

I need to test an ASP.NET web site with multiple http sessions, using a
command line C# application. My idea is to run (at least) two threads to
emulate the different sessions, with each threat polling the web site to
emulate different requests within the same session. In the test phase we
can assume the following code:

public partial class TestPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Diagnostic.DefaultTraceListener dtl = ...;

dtl.WriteLine(HttpContext.Current.Session.GetHashCode().ToString());
}
}

The problem is that I cannot handle the sessions client side. Googling
around I found something about cookies, so I wrote this snippet down:

string requestUrl = "...";
int requestNo = 10;

CookieContainer cc = null;
for (int i = 0; i < requestNo; i++)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUrl);
request.CookieContainer = cc;
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();

cc = new CookieContainer();
foreach (Cookie c in response.Cookies)
cc.Add(c);
}

but at the first step 'response.Cookies' is empty.
Am I missing anything on the server-side? Am I missing anything *at
all*? ;-)

Thanks in advance,
Giulio
--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top