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