473,785 Members | 2,209 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

all cookies disappear after round trip to client

Hi,

I have a web app, there is only really 1 aspx page (that the user never
sees) the rest of the code is done in a DLL that implements HttpHandler.
My app (which is a porting job from Vb6 webclasses) needs to use session
cookies (i.e. when all browser windows are closed the cookies disappear)
however in my code the cookies disappear after a round trip to the client
browser, i.e:

Browser
|
- request
|
web server - does code, sets cookies
|
- response
|
Browser
|
- request
|
web server - checks cookie set from 1st request *&%!!"- they are all gone.

I have an asp wrapper class that has a member variable of type Httpcontext
this gives me access to all the asp objects like request etc...
I have a property ClientVars() which wraps up the cookie access. What
ClientVars() does to set a cookie is this:

m_context.Respo nse.Cookies(m_s trCookieName)(s trName) = Value

And I get the cookie (after a decision) with either:

m_context.Respo nse.Cookies(m_s trCookieName)(s trName)
or
m_context.Reque st.Cookies(m_st rCookieName)(st rName)

The reason for the above decision in the get bit is so that if I set a
cookie and then in the same request ask for the cookie again it will give it
me from the response instead of the request.

m_strCookieName gets set when the my asp wrapper class is initialised to the
path from URL, i.e. if my url was http://localhost/testVersion, then
m_strCookieName would be "testVersio n", if the url was http://localhost it
would be an empty string.

The pages that the user gets includes JS that creates a cookieJar (from the
O'Reily JS books), but the cookies I am interested in on the 2nd request are
not touched my the JS cookieJar stuff in terms of setting, and even if they
were my .NET code should still be able to see the ones it initially set.

One curious thing that I do see on the 2nd request (side effect of JS
perhaps?) is that in the Request.Cookies .AllKeys collection (given the
example URL above) there are now 2 keys called "testVersio n" whereas during
the 1st request there was only one. If I access either of them using there
index values:

? m_context.Reque st.Cookies(1)(0 )
or
? m_context.Reque st.Cookies(3)(0 )

The cookies in between index 1 and 3 are things like ASP__SESSION or
similar, which I don't use and didn't set.

....respectivel y then each returns Nothing, so all my cookies set in 1st
request have disappeared.

Any help working out where these cookies are going would be highly
appreciated.

Regards,
Peter Row
Nov 18 '05 #1
1 3346
This link may help

http://www.codeproject.com/aspnet/aspnetcookies.asp

"Peter Row" <pe*******@oxfo rdcc.co.uk> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi,

I have a web app, there is only really 1 aspx page (that the user never
sees) the rest of the code is done in a DLL that implements HttpHandler.
My app (which is a porting job from Vb6 webclasses) needs to use session
cookies (i.e. when all browser windows are closed the cookies disappear)
however in my code the cookies disappear after a round trip to the client
browser, i.e:

Browser
|
- request
|
web server - does code, sets cookies
|
- response
|
Browser
|
- request
|
web server - checks cookie set from 1st request *&%!!"- they are all gone.

I have an asp wrapper class that has a member variable of type Httpcontext
this gives me access to all the asp objects like request etc...
I have a property ClientVars() which wraps up the cookie access. What
ClientVars() does to set a cookie is this:

m_context.Respo nse.Cookies(m_s trCookieName)(s trName) = Value

And I get the cookie (after a decision) with either:

m_context.Respo nse.Cookies(m_s trCookieName)(s trName)
or
m_context.Reque st.Cookies(m_st rCookieName)(st rName)

The reason for the above decision in the get bit is so that if I set a
cookie and then in the same request ask for the cookie again it will give it me from the response instead of the request.

m_strCookieName gets set when the my asp wrapper class is initialised to the path from URL, i.e. if my url was http://localhost/testVersion, then
m_strCookieName would be "testVersio n", if the url was http://localhost it
would be an empty string.

The pages that the user gets includes JS that creates a cookieJar (from the O'Reily JS books), but the cookies I am interested in on the 2nd request are not touched my the JS cookieJar stuff in terms of setting, and even if they were my .NET code should still be able to see the ones it initially set.

One curious thing that I do see on the 2nd request (side effect of JS
perhaps?) is that in the Request.Cookies .AllKeys collection (given the
example URL above) there are now 2 keys called "testVersio n" whereas during the 1st request there was only one. If I access either of them using there
index values:

? m_context.Reque st.Cookies(1)(0 )
or
? m_context.Reque st.Cookies(3)(0 )

The cookies in between index 1 and 3 are things like ASP__SESSION or
similar, which I don't use and didn't set.

...respectively then each returns Nothing, so all my cookies set in 1st
request have disappeared.

Any help working out where these cookies are going would be highly
appreciated.

Regards,
Peter Row

Nov 18 '05 #2

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

Similar topics

20
3558
by: Brian Burgess | last post by:
Hi all, Anyone know if this is possible? If so, on which page would the cookie be? .. On the page calling a function defined in the include file? thanks in advance.. -BB
0
1007
by: charliewest | last post by:
I am using a data grid control to present info on an ASP.NET web form. When clicking buttons, i can show or hide columns and rows, however, this requires a round-trip back to the server. Is there any control (freely available or proprietary) that enables data grids, or web table controls for that matter, to "expand" on the client-side, without making a round trip? Obviously this can be done w/ DHTML, but i am trying to stick w/ C# for...
2
1826
by: Homer J. Simpson | last post by:
Hi there, I need to maintain users choices among different sessions. So i'd like to use a kind of server-side cookies, just to be sure he won't delete or reject the cookie, depending on the client security level. But i can't find a way to do it, except using the FileStream Class. Any other ideas ? Thxs in advance,
2
324
by: Yanir | last post by:
H I have to display a sortable list of columns(a table or so) - by click on the title of a column, the column would be the criteria to sort by I know datagrid is very conveniant, but I want to save the round trip to the server(I don't want postback) Is there other way to use ASP.NET server controls(maybe the datagrid itself) to have an easy databound from one hand and client sort from second May be a technique that tranform a XSL on a...
2
1391
by: Mike | last post by:
Hello, I have a web user control that contains a ListBox. I would like to display some information based on the double-clicking of the user on a ListBox's item. I was thinking about some code behind procedure to do that, but I am a little bit worried about round-trip to the web server. Every time the user clicks on an item, a round-trip to the server is made. Is there a better solution to avoid these round-trips? Thanks. Mike
4
1388
by: Steve Commisso | last post by:
I'm working with the following scenario: I'm building a wizard. Each 'step' of the wizard is its own User Control page. I'm trying to minimize the 'round trips' (e.g. runat=server) I make to the server so I want to try to do the following: When the user clicks the 'next' button on one user control, that control disappears and the next 'step' in the wizard appears. So to dothis, I load all of the User Controls as web parts, and then
3
2086
by: Calvin KD | last post by:
Hi everyone, Can someone tell me what's wrong with the way that i read a cookie as below: private void Page_Load(object sender, System.EventArgs e) { Response.Cookies.Clear(); HttpCookie cookie = GetSessionCookie("MyCookie", "duh"); } private HttpCookie GetSessionCookie(string cookieKey, string cookieValue)
8
1777
by: needin4mation | last post by:
I understand this is a asp.net group, but thought I would post this here for comments. I admit I have used this post in another group, but it has less traffic. Here's to hoping I'm just blind to the obvious: I have been reading a lot about AJAX. I want to use it and will. But I keep reading about how it doesn't make a roundtrip to the server, no postback, etc. But isn't the truth that *something* makes a trip to the server? It may...
7
3363
by: Tony Girgenti | last post by:
Hello. I'm trying to undetrstand ASP.NET 2.0 and javascript. When i have a button and i click on it and i see the web broswer progress bar at the bottom do something, does that mean that there is postback occurring? Does that mean a round trip to the server occurred? I keep reading javascript articles and tutorials that say "improve the client-side experience to be more responsive and quicker", but the articles
0
9483
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10346
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10157
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8982
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.