468,291 Members | 1,497 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,291 developers. It's quick & easy.

Cookie not set fast enough

I have an application that sets a cookie through a class. I set it in a push
button event on a postback. When the page reloads, a user control checks the
value of that cookie to display name information. The problem is - the
cookie is not being set fast enough for the user control to find it. Can you
offer any solution?

Thanks,
Denise
Nov 19 '05 #1
6 1405
Denise wrote:
I have an application that sets a cookie through a class. I set it in a push
button event on a postback. When the page reloads, a user control checks the
value of that cookie to display name information. The problem is - the
cookie is not being set fast enough for the user control to find it. Can you
offer any solution?

Thanks,
Denise


Huh? I dont think that's possible. If it's linearly executed code its
not possible. Are you sure there isn't a potential issue elsewhere?
Perhaps cookies aren't allowed, not set properly, not called properly, etc?

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
Nov 19 '05 #2
How are you writing the cookie? Could you provide some code?

Clint Hill
H3O Software
http://www.h3osoftware.com

Denise wrote:
I have an application that sets a cookie through a class. I set it in a push
button event on a postback. When the page reloads, a user control checks the
value of that cookie to display name information. The problem is - the
cookie is not being set fast enough for the user control to find it. Can you
offer any solution?

Thanks,
Denise

Nov 19 '05 #3
I am guessing you have a user control on the same page as the button, and
you are looking for this in the user control's Load event? In which case,
the button's Click event is going to run after the Load event of the user
control (and the page this is all on for that matter).

You need to restructure the way your page communicates with the user control
and when you are pulling information out.

"Denise" <De****@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
I have an application that sets a cookie through a class. I set it in a
push
button event on a postback. When the page reloads, a user control checks
the
value of that cookie to display name information. The problem is - the
cookie is not being set fast enough for the user control to find it. Can
you
offer any solution?

Thanks,
Denise

Nov 19 '05 #4
It is happening - but not all the time. If I step through the code, it works
as expected. It works fine 80% of the time, but there are other times when
it pulls the prior cookie and reloads the wrong row.

private void NewButon_Click(...)
{
HttpCookie Cookie = new HttpCookie("CaseId", 0);
HttpContext Current.Response.Cookies.Add(Cookie);

LoadData();
}

private void LoadData()
{
HttpCookie Cookie = HttpContext.Current.Request.Cookies["CaseId"];
///Sometimes Cookie is equal to the prior cookie set !!!!
}

Actually, I was setting the cookies in a separate class using the
HTTPContext. When I tried pasting it directly into my code, I was using
Response.Cookies, but both seemed not to work well.

"Curt_C [MVP]" wrote:
Denise wrote:
I have an application that sets a cookie through a class. I set it in a push
button event on a postback. When the page reloads, a user control checks the
value of that cookie to display name information. The problem is - the
cookie is not being set fast enough for the user control to find it. Can you
offer any solution?

Thanks,
Denise


Huh? I dont think that's possible. If it's linearly executed code its
not possible. Are you sure there isn't a potential issue elsewhere?
Perhaps cookies aren't allowed, not set properly, not called properly, etc?

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

Nov 19 '05 #5
See above post

"Clint Hill" wrote:
How are you writing the cookie? Could you provide some code?

Clint Hill
H3O Software
http://www.h3osoftware.com

Denise wrote:
I have an application that sets a cookie through a class. I set it in a push
button event on a postback. When the page reloads, a user control checks the
value of that cookie to display name information. The problem is - the
cookie is not being set fast enough for the user control to find it. Can you
offer any solution?

Thanks,
Denise

Nov 19 '05 #6
Yes, that is happening as well...I have one case where the user control is
loading before the cookie has been set, but that is not the problem I am
having. See above post.

"Marina" wrote:
I am guessing you have a user control on the same page as the button, and
you are looking for this in the user control's Load event? In which case,
the button's Click event is going to run after the Load event of the user
control (and the page this is all on for that matter).

You need to restructure the way your page communicates with the user control
and when you are pulling information out.

"Denise" <De****@discussions.microsoft.com> wrote in message
news:74**********************************@microsof t.com...
I have an application that sets a cookie through a class. I set it in a
push
button event on a postback. When the page reloads, a user control checks
the
value of that cookie to display name information. The problem is - the
cookie is not being set fast enough for the user control to find it. Can
you
offer any solution?

Thanks,
Denise


Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by Jochen Daum | last post: by
7 posts views Thread by What-a-Tool | last post: by
2 posts views Thread by George Durzi | last post: by
3 posts views Thread by Ben | last post: by
4 posts views Thread by gl | last post: by
6 posts views Thread by Victor | last post: by
2 posts views Thread by Sean | last post: by
reply views Thread by Chris Rebert | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.