Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Using Cookies

Reply
Thread Tools

Using Cookies

 
 
Giulio Petrucci
Guest
Posts: n/a
 
      11-18-2009
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.GetHashC ode().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
--
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Give Request.Cookies and Response.Cookies is there any reason to use another method to use cookies? _Who ASP .Net 7 09-18-2008 07:49 PM
What's the proper way of reading cookies? Request.Cookies("mycook") doesnt work user ASP .Net 3 03-31-2007 01:53 PM
Response.Cookies vs Request.Cookies Alex Nitulescu ASP .Net 1 02-03-2005 09:43 AM
Persistent Cookies vs. session cookies Andy Fish Java 3 11-06-2003 10:44 AM
Good Cookies bad Cookies? AK Computer Support 23 10-26-2003 05:20 AM



Advertisments