By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,877 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,877 IT Pros & Developers. It's quick & easy.

Cookie munging problem

P: n/a
Hi,

I'm trying to use the cookie munging session handling behaviour of asp.net
instead of cookies themselves as I'm finding quite a few people are barring
cookies (especially AOL users). If I change the setting in web.config
everything seems to work fine as long as I'm using relative paths. The
problem is I've got a menuing system that's generated from a site-wide
template - so I use a fixed path from the application root - (ie:
/application/sub-dir/page.aspx) because I don't actually know where the
user is at any given moment because it's a site-wide menu.

Whenever someone clicks on one of them, the Session ID gets wiped from the
URL and the user gets logged out. Am I missing something really stupid
here? How can I persist the SessionID in these URLs?

Cheers

Chris
Nov 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
I had the same problem and wound up changing the menu system so that my
navigation is in 4 different controls vs. one. Each control is located in a
position so that it can use relative paths with respect to the page. Instead
of making a change in one nav control I have to make it in 4 but it is still
worth it in order to use cookie munging. My users refuse to allow cookies.
Hope your post results in a better option , I'd love to get back to using
one nav control vs 4.
<ch***@yahoo.com> wrote in message
news:ex*************@tk2msftngp13.phx.gbl...
Hi,

I'm trying to use the cookie munging session handling behaviour of asp.net
instead of cookies themselves as I'm finding quite a few people are barring cookies (especially AOL users). If I change the setting in web.config
everything seems to work fine as long as I'm using relative paths. The
problem is I've got a menuing system that's generated from a site-wide
template - so I use a fixed path from the application root - (ie:
/application/sub-dir/page.aspx) because I don't actually know where the
user is at any given moment because it's a site-wide menu.

Whenever someone clicks on one of them, the Session ID gets wiped from the
URL and the user gets logged out. Am I missing something really stupid
here? How can I persist the SessionID in these URLs?

Cheers

Chris

Nov 17 '05 #2

P: n/a
Well that looks interesting. All of my navigation links are generated using
the asp server side controls. Hadn't thought of using the code behind to set
up the urls though. Can you give me a bit of help in getting started on
this? For example if I have the following:

Root
default.aspx consisting of 1 nav user control nav.ascx

Root/subfolderA
PageA.aspx consisting of 1 nav user control nav.ascx

Root/subfolderA/subfolderB
PageAB.aspx consisting of 1 nav user control nav.ascx
Right now I would have to code each user control seperately based on their
relative position in the web even though each nav.ascx displays all the
files the user needs to get to. (of course the premise is that I wish to
continue to use cookie munging.) This is because each user control is
relative depending on the aspx page that calls it vs where it (the ascx)
actually exists.

If I understand your suggestion correctly you are saying that I could keep
one (my root for example) nav.ascx and use it from any aspx page within the
heirarchy by referencing the session.sessionid in the nav.ascx code behind?I
f that is true it would certainly solve the problem.

Can you give me a simple (I'm not very bright) example of the code for the
code behind and the ascx code for a couple of levels (maybe using the folder
structure I mentioned earlier)? Actually just one would probably do me. For
example how would I reference the session.sessionid in the code behind and
then retrieve that in the asp hyperlink?

Thanks in advance.


<ch***@yahoo.com> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
Hi Seaside,

I think I've figured out how to do it. May or may not work for you. My menu is an asp.net menu created server side, so i've basically changed the base
url (ie: "/site/") to "/site/(sjkfj23jsdfjlsdkfj)/" note - the sjkfj23.... etc. is referenced in code behind using session.sessionID

If your menu is generated server side, then this will work for you. If it's just a client-side menu that you don't generate in code, then it won't.

Hope that helps???

Chris

"Seaside" <ss@hotmail.com> wrote in message
news:uu**************@TK2MSFTNGP10.phx.gbl...
I had the same problem and wound up changing the menu system so that my
navigation is in 4 different controls vs. one. Each control is located in
a
position so that it can use relative paths with respect to the page.

Instead
of making a change in one nav control I have to make it in 4 but it is

still
worth it in order to use cookie munging. My users refuse to allow cookies. Hope your post results in a better option , I'd love to get back to using one nav control vs 4.
<ch***@yahoo.com> wrote in message
news:ex*************@tk2msftngp13.phx.gbl...
Hi,

I'm trying to use the cookie munging session handling behaviour of

asp.net instead of cookies themselves as I'm finding quite a few people are

barring
cookies (especially AOL users). If I change the setting in web.config
everything seems to work fine as long as I'm using relative paths. The problem is I've got a menuing system that's generated from a site-wide
template - so I use a fixed path from the application root - (ie:
/application/sub-dir/page.aspx) because I don't actually know where the user is at any given moment because it's a site-wide menu.

Whenever someone clicks on one of them, the Session ID gets wiped from the URL and the user gets logged out. Am I missing something really stupid here? How can I persist the SessionID in these URLs?

Cheers

Chris



Nov 17 '05 #3

P: n/a
Sure, it's simple.

Basically, use only one nav.ascx.

When you set up the urls, do so server side using absolute links instead of
relative.

So for example, let's assume your application is called MyApp and it's in a
virtualdirectory called MyApp.

It's root directory looks like:

default.aspx
subfolderA/page1.aspx
subfolderB/page2.aspx

All 3 pages have the same nav.ascx control.

The URLs would have to be generated server side, so you'd have to do
something like (assuming nav.ascx code behind is a class called nav):

nav.HomeURL = "/MyApp/(" + session.sessionID + ")/Default.aspx"
nav.Page1URL = "/MyApp/(" + session.sessionID + ")/subfolderA/page1.aspx"
nav.Page2URL = "/MyApp/(" + session.sessionID + ")/subfolderB/page2.aspx"

This definately does work - as i've got it working on my site. Now the only
problem is if the user leaves the site (like to go to a credit card
processing page hosted elsewhere) and comes back - you need to persist the
sessionID somehow....

Hope that helps

Chris

"Seaside" <ss@hotmail.com> wrote in message
news:eY****************@tk2msftngp13.phx.gbl...
Well that looks interesting. All of my navigation links are generated using the asp server side controls. Hadn't thought of using the code behind to set up the urls though. Can you give me a bit of help in getting started on
this? For example if I have the following:

Root
default.aspx consisting of 1 nav user control nav.ascx

Root/subfolderA
PageA.aspx consisting of 1 nav user control nav.ascx

Root/subfolderA/subfolderB
PageAB.aspx consisting of 1 nav user control nav.ascx
Right now I would have to code each user control seperately based on their
relative position in the web even though each nav.ascx displays all the
files the user needs to get to. (of course the premise is that I wish to
continue to use cookie munging.) This is because each user control is
relative depending on the aspx page that calls it vs where it (the ascx)
actually exists.

If I understand your suggestion correctly you are saying that I could keep
one (my root for example) nav.ascx and use it from any aspx page within the heirarchy by referencing the session.sessionid in the nav.ascx code behind?I f that is true it would certainly solve the problem.

Can you give me a simple (I'm not very bright) example of the code for the
code behind and the ascx code for a couple of levels (maybe using the folder structure I mentioned earlier)? Actually just one would probably do me. For example how would I reference the session.sessionid in the code behind and
then retrieve that in the asp hyperlink?

Thanks in advance.


<ch***@yahoo.com> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
Hi Seaside,

I think I've figured out how to do it. May or may not work for you. My

menu
is an asp.net menu created server side, so i've basically changed the base
url (ie: "/site/") to "/site/(sjkfj23jsdfjlsdkfj)/" note - the

sjkfj23....
etc. is referenced in code behind using session.sessionID

If your menu is generated server side, then this will work for you. If

it's
just a client-side menu that you don't generate in code, then it won't.

Hope that helps???

Chris

"Seaside" <ss@hotmail.com> wrote in message
news:uu**************@TK2MSFTNGP10.phx.gbl...
I had the same problem and wound up changing the menu system so that my navigation is in 4 different controls vs. one. Each control is located in
a
position so that it can use relative paths with respect to the page.

Instead
of making a change in one nav control I have to make it in 4 but it is

still
worth it in order to use cookie munging. My users refuse to allow

cookies. Hope your post results in a better option , I'd love to get back to using one nav control vs 4.
<ch***@yahoo.com> wrote in message
news:ex*************@tk2msftngp13.phx.gbl...
> Hi,
>
> I'm trying to use the cookie munging session handling behaviour of

asp.net
> instead of cookies themselves as I'm finding quite a few people are
barring
> cookies (especially AOL users). If I change the setting in web.config > everything seems to work fine as long as I'm using relative paths. The > problem is I've got a menuing system that's generated from a site-wide > template - so I use a fixed path from the application root - (ie:
> /application/sub-dir/page.aspx) because I don't actually know where the > user is at any given moment because it's a site-wide menu.
>
> Whenever someone clicks on one of them, the Session ID gets wiped
from the
> URL and the user gets logged out. Am I missing something really

stupid > here? How can I persist the SessionID in these URLs?
>
> Cheers
>
> Chris
>
>



Nov 17 '05 #4

P: n/a
Super! Thanks bunches!
<ch***@yahoo.com> wrote in message
news:uA**************@tk2msftngp13.phx.gbl...
Sure, it's simple.

Basically, use only one nav.ascx.

When you set up the urls, do so server side using absolute links instead of relative.

So for example, let's assume your application is called MyApp and it's in a virtualdirectory called MyApp.

It's root directory looks like:

default.aspx
subfolderA/page1.aspx
subfolderB/page2.aspx

All 3 pages have the same nav.ascx control.

The URLs would have to be generated server side, so you'd have to do
something like (assuming nav.ascx code behind is a class called nav):

nav.HomeURL = "/MyApp/(" + session.sessionID + ")/Default.aspx"
nav.Page1URL = "/MyApp/(" + session.sessionID + ")/subfolderA/page1.aspx"
nav.Page2URL = "/MyApp/(" + session.sessionID + ")/subfolderB/page2.aspx"

This definately does work - as i've got it working on my site. Now the only problem is if the user leaves the site (like to go to a credit card
processing page hosted elsewhere) and comes back - you need to persist the
sessionID somehow....

Hope that helps

Chris

"Seaside" <ss@hotmail.com> wrote in message
news:eY****************@tk2msftngp13.phx.gbl...
Well that looks interesting. All of my navigation links are generated

using
the asp server side controls. Hadn't thought of using the code behind to

set
up the urls though. Can you give me a bit of help in getting started on
this? For example if I have the following:

Root
default.aspx consisting of 1 nav user control nav.ascx

Root/subfolderA
PageA.aspx consisting of 1 nav user control nav.ascx

Root/subfolderA/subfolderB
PageAB.aspx consisting of 1 nav user control nav.ascx
Right now I would have to code each user control seperately based on their
relative position in the web even though each nav.ascx displays all the
files the user needs to get to. (of course the premise is that I wish to
continue to use cookie munging.) This is because each user control is
relative depending on the aspx page that calls it vs where it (the ascx)
actually exists.

If I understand your suggestion correctly you are saying that I could keep one (my root for example) nav.ascx and use it from any aspx page within

the
heirarchy by referencing the session.sessionid in the nav.ascx code

behind?I
f that is true it would certainly solve the problem.

Can you give me a simple (I'm not very bright) example of the code for the code behind and the ascx code for a couple of levels (maybe using the

folder
structure I mentioned earlier)? Actually just one would probably do me.

For
example how would I reference the session.sessionid in the code behind and then retrieve that in the asp hyperlink?

Thanks in advance.


<ch***@yahoo.com> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
Hi Seaside,

I think I've figured out how to do it. May or may not work for you. My
menu
is an asp.net menu created server side, so i've basically changed the base url (ie: "/site/") to "/site/(sjkfj23jsdfjlsdkfj)/" note - the

sjkfj23....
etc. is referenced in code behind using session.sessionID

If your menu is generated server side, then this will work for you.
If it's
just a client-side menu that you don't generate in code, then it
won't.
Hope that helps???

Chris

"Seaside" <ss@hotmail.com> wrote in message
news:uu**************@TK2MSFTNGP10.phx.gbl...
> I had the same problem and wound up changing the menu system so that

my > navigation is in 4 different controls vs. one. Each control is located in
a
> position so that it can use relative paths with respect to the page.
Instead
> of making a change in one nav control I have to make it in 4 but it
is still
> worth it in order to use cookie munging. My users refuse to allow

cookies.
> Hope your post results in a better option , I'd love to get back to

using
> one nav control vs 4.
>
>
> <ch***@yahoo.com> wrote in message
> news:ex*************@tk2msftngp13.phx.gbl...
> > Hi,
> >
> > I'm trying to use the cookie munging session handling behaviour of
asp.net
> > instead of cookies themselves as I'm finding quite a few people are > barring
> > cookies (especially AOL users). If I change the setting in web.config > > everything seems to work fine as long as I'm using relative paths.

The
> > problem is I've got a menuing system that's generated from a site-wide > > template - so I use a fixed path from the application root - (ie:
> > /application/sub-dir/page.aspx) because I don't actually know
where the
> > user is at any given moment because it's a site-wide menu.
> >
> > Whenever someone clicks on one of them, the Session ID gets wiped

from the
> > URL and the user gets logged out. Am I missing something really

stupid
> > here? How can I persist the SessionID in these URLs?
> >
> > Cheers
> >
> > Chris
> >
> >
>
>



Nov 17 '05 #5

P: n/a
Ooops. I seem to be running into a problem. Perhaps I don't fully grasp the
technique although I appreciate the concept.
When you say
When you set up the urls, do so server side using absolute links instead of relative.
You mean using a <asp:hyperlink runat: = "server"> tag.....correct?

If so then in the NavigateUrl="" attribute of the asp:hyperlink I would
place the variable which was referenced in the code behind for that
particular URL. For example <asp:hyperlink runat: = "server"
navigateurl=nav.HomeUrl >

Is that correct?

If so then I must not be setting the reference correctly in the code behind
of the nav.ascx. Where in the code behind and how are you placing that
reference? I tried dimming a variable as a string inside the code behind
class and then assigning the absolute path as you instructed but I suspect
that I didn't do it correctly because it couldn't find the page. I can't
figure out if I'm not setting the reference correctly or I'm not using the
reference correctly in the <asp:hyperlink> tag.
Thanks again.




<ch***@yahoo.com> wrote in message
news:uA**************@tk2msftngp13.phx.gbl... Sure, it's simple.

Basically, use only one nav.ascx.

When you set up the urls, do so server side using absolute links instead of relative.

So for example, let's assume your application is called MyApp and it's in a virtualdirectory called MyApp.

It's root directory looks like:

default.aspx
subfolderA/page1.aspx
subfolderB/page2.aspx

All 3 pages have the same nav.ascx control.

The URLs would have to be generated server side, so you'd have to do
something like (assuming nav.ascx code behind is a class called nav):

nav.HomeURL = "/MyApp/(" + session.sessionID + ")/Default.aspx"
nav.Page1URL = "/MyApp/(" + session.sessionID + ")/subfolderA/page1.aspx"
nav.Page2URL = "/MyApp/(" + session.sessionID + ")/subfolderB/page2.aspx"

This definately does work - as i've got it working on my site. Now the only problem is if the user leaves the site (like to go to a credit card
processing page hosted elsewhere) and comes back - you need to persist the
sessionID somehow....

Hope that helps

Chris

"Seaside" <ss@hotmail.com> wrote in message
news:eY****************@tk2msftngp13.phx.gbl...
Well that looks interesting. All of my navigation links are generated

using
the asp server side controls. Hadn't thought of using the code behind to

set
up the urls though. Can you give me a bit of help in getting started on
this? For example if I have the following:

Root
default.aspx consisting of 1 nav user control nav.ascx

Root/subfolderA
PageA.aspx consisting of 1 nav user control nav.ascx

Root/subfolderA/subfolderB
PageAB.aspx consisting of 1 nav user control nav.ascx
Right now I would have to code each user control seperately based on their
relative position in the web even though each nav.ascx displays all the
files the user needs to get to. (of course the premise is that I wish to
continue to use cookie munging.) This is because each user control is
relative depending on the aspx page that calls it vs where it (the ascx)
actually exists.

If I understand your suggestion correctly you are saying that I could keep one (my root for example) nav.ascx and use it from any aspx page within

the
heirarchy by referencing the session.sessionid in the nav.ascx code

behind?I
f that is true it would certainly solve the problem.

Can you give me a simple (I'm not very bright) example of the code for the code behind and the ascx code for a couple of levels (maybe using the

folder
structure I mentioned earlier)? Actually just one would probably do me.

For
example how would I reference the session.sessionid in the code behind and then retrieve that in the asp hyperlink?

Thanks in advance.


<ch***@yahoo.com> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
Hi Seaside,

I think I've figured out how to do it. May or may not work for you. My
menu
is an asp.net menu created server side, so i've basically changed the base url (ie: "/site/") to "/site/(sjkfj23jsdfjlsdkfj)/" note - the

sjkfj23....
etc. is referenced in code behind using session.sessionID

If your menu is generated server side, then this will work for you.
If it's
just a client-side menu that you don't generate in code, then it
won't.
Hope that helps???

Chris

"Seaside" <ss@hotmail.com> wrote in message
news:uu**************@TK2MSFTNGP10.phx.gbl...
> I had the same problem and wound up changing the menu system so that

my > navigation is in 4 different controls vs. one. Each control is located in
a
> position so that it can use relative paths with respect to the page.
Instead
> of making a change in one nav control I have to make it in 4 but it
is still
> worth it in order to use cookie munging. My users refuse to allow

cookies.
> Hope your post results in a better option , I'd love to get back to

using
> one nav control vs 4.
>
>
> <ch***@yahoo.com> wrote in message
> news:ex*************@tk2msftngp13.phx.gbl...
> > Hi,
> >
> > I'm trying to use the cookie munging session handling behaviour of
asp.net
> > instead of cookies themselves as I'm finding quite a few people are > barring
> > cookies (especially AOL users). If I change the setting in web.config > > everything seems to work fine as long as I'm using relative paths.

The
> > problem is I've got a menuing system that's generated from a site-wide > > template - so I use a fixed path from the application root - (ie:
> > /application/sub-dir/page.aspx) because I don't actually know
where the
> > user is at any given moment because it's a site-wide menu.
> >
> > Whenever someone clicks on one of them, the Session ID gets wiped

from the
> > URL and the user gets logged out. Am I missing something really

stupid
> > here? How can I persist the SessionID in these URLs?
> >
> > Cheers
> >
> > Chris
> >
> >
>
>



Nov 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.