Ask a Question related to ASP.NET General, Design and Development.
-
adlaird@earthlink.net #1
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
adlaird@earthlink.net Guest
-
Strange behavior
The problem seems to be in c code calling ruby calling c code. ======== start test.rb puts "about to require curses" require "curses" puts... -
Strange behavior of $.
Apparently $. is not always set correct (see second ruby 1liner). Is this a bug? 12:12:42 : cat -n n 1 2 3 BAR="hello" 4 12:12:47 : ruby... -
Re[2]: Strange behavior of DBI/DBD::Informix
Thank you for the reply. Sorry, I wrote late in the evening and forgot to post my configuration: Perl 5.6.1 AIX 4.2.1 (I know it's old... -
Strange behavior of DBD/DBI Informix
I am not sure if this list is the best one to post to regarding this problem. If not please point me to the better one. Consider the following... -
Why strange IF...ELSE behavior
Hi all, I'm getting a strange result with the following IF statement: $bar = ($foo == 'last') ? true : false; In my script $foo normaly has... -
Chris R. Timmons #2
Re: Strange behavior with HttpCookieCollection
[email]adlaird@earthlink.net[/email] wrote in
news:3f18afd7.184287250@news.earthlink.net:
You've stumbled upon a frustrating (and, AFAIK, undocumented) aspect> 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?
of the ASP.NET cookies response collection. Simply querying the
collection will create the cookie if it doesn't exist.
Here's an article that explains this in more depth:
[url]http://www.codeproject.com/aspnet/AspNetCookies.asp[/url]
Hope this helps.
Chris.
-------------
C.R. Timmons Consulting, Inc.
[url]http://www.crtimmonsinc.com/[/url]
Chris R. Timmons Guest



Reply With Quote

