473,406 Members | 2,849 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,406 software developers and data experts.

Strange behavior with HttpCookieCollection

Hi,

I created a simple webform, put a test button on it and implemented a
click handler that looks like so:

private void btnTest_Click(object sender, System.EventArgs e)
{
HttpCookieCollection oCookReq =
HttpContext.Current.Request.Cookies;
HttpCookieCollection oCookResp =
HttpContext.Current.Response.Cookies;

int n1 = oCookReq.Count;
int n2 = oCookResp.Count;
bool bIsNull = (oCookResp["someCookieName"] == null);
int n3 = oCookReq.Count;
int n4 = oCookResp.Count;

Response.Write(string.Format("Before: Request = {0}, Response
= {1}<br>", n1, n2));
Response.Write(string.Format("After: Request = {0}, Response
= {1}<br>", n3, n4));
}
When I click the button the test output on the page is:

Before: Request = 1, Response = 0
After: Request = 2, Response = 1

Can anyone explain why the mere act of looking for a cookie in the
response collection would cause one to get added to both the response
and request collections? I tried the test again using a new
HttpCookieCollection (i.e. not one from the current context) and do
not get this behavior. Clues?

Thanks much...

- A

Nov 13 '05 #1
0 1284

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

Similar topics

1
by: adlaird | last post by:
Hi, I created a simple webform, put a test button on it and implemented a click handler that looks like so: private void btnTest_Click(object sender, System.EventArgs e) {...
1
by: Alexander Inochkin | last post by:
Hi! I found same strange behavior of ASP.NET. It is possible this is the bug. Follow the steps:
0
by: ivb | last post by:
Hi all, I am using DB2 8.1.11.1 on NT with ASP.NET 1.1 When application make connection to database (via ADO.NET), it set "Connection timeout" parameter to 30 seconds. After, when my webpage...
6
by: Joseph Geretz | last post by:
Writing an Outlook AddIn with C#. For the user interface within Outlook I'm adding matching pairs of Toolbar buttons and Menu items. All of the buttons and menu items are wired up to send events to...
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: 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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.