EXTREMELY odd cookie behavior

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
N

news.microsoft.com

I have an extremely odd cookie problem and had many programmers in the group
looked at it but still with no solution. The following is the synptom:
I have a user control ( for inputting user information) used in many apsx
files. And I used a cookie in the control to remember the inputs. After the
user input the values and click "submit", server will unload this control
and load some other user control. Here is the problem: if I come back to the
same aspx page again after inputing the values in the control, the page can
still "remember" the old values and "lost" the updated information I have
input. It looks like the cookie was not written successfully; HOWEVER the
updated information would appear in other aspx pages that have the same user
control!
Since it looks like a page caching problem, I then added following
statements
<META Http-Equiv="Cache-Control" Content="no-cache">
<META Http-Equiv="Pragma" Content="no-cache">
<META Http-Equiv="Expires" Content="0">
to all involoved aspx files (I don't know how to disable cache in user
control though), and it still behaves the same. Later on I found the problem
will go away if I killed aspnet_wp.exe process from task manger.
I am totally lost. Any help will be greatly appreciated.


Xiaowei
 
I have an extremely odd cookie problem and had many programmers in the
group
looked at it but still with no solution. The following is the synptom:
I have a user control ( for inputting user information) used in many apsx
files. And I used a cookie in the control to remember the inputs. After the
user input the values and click "submit", server will unload this control
and load some other user control. Here is the problem: if I come back to the
same aspx page again after inputing the values in the control, the page can
still "remember" the old values and "lost" the updated information I have
input.

I have no idea if this is in anyway related to your issue, but I've found
one common issue with cookies is that you write the new cookie values on
postback, but that often happens after the page renders. So the page
'appears' to not have updated the cookie.

The fix in my case was to re-read the cookie on the page render.

-Darrel
 
news.microsoft.com said:
I have an extremely odd cookie problem and had many programmers in
the group looked at it but still with no solution. The following is
the synptom: I have a user control ( for inputting user information)
used in many apsx files. And I used a cookie in the control to
remember the inputs. After the user input the values and click
"submit", server will unload this control and load some other user
control. Here is the problem: if I come back to the same aspx page
again after inputing the values in the control, the page can still
"remember" the old values and "lost" the updated information I have
input. It looks like the cookie was not written successfully; HOWEVER
the updated information would appear in other aspx pages that have
the same user control! Since it looks like a page caching problem, I
then added following statements
<META Http-Equiv="Cache-Control" Content="no-cache">
<META Http-Equiv="Pragma" Content="no-cache">
<META Http-Equiv="Expires" Content="0">
to all involoved aspx files (I don't know how to disable cache in user
control though), and it still behaves the same. Later on I found the
problem will go away if I killed aspnet_wp.exe process from task
manger. I am totally lost. Any help will be greatly appreciated.

Repeat after me:

META tags are not a proper way to prevent caching.
META tags are not a proper way to prevent caching.
META tags are not a proper way to prevent caching.

(Do it a couple of times more ;->)

Now... try System.Web.HttpCachePolicy, e.g.
Response.Cache.SetCacheability(HttpCacheability.NoCache);

Cheers,
 
Back
Top