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

Possible to 'recapture' a asp.net session?

P: n/a
I have an ASP.Net 2.0 app that needs to jump out onto another web
server running a java server page website (Apache TomCat 4.1.12) that
I control. I hate that it needs to do this, but we are using some
internet GIS mapping web tool that comes "precanned" with lots of
mapping ability and its pages run on JSP. Theasp.net Session_End event
is quite important to catch as there is a lot of cleanup that needs to
happen in the database relating to the user of that session. Thus, I
need to maintain the session across ASP.Net and JSP webservers. A
hackish way that I accomplished this was to use cookieless sessions
which embeds the session id in the url (e.g.
http://www.abc.com/(S(2zmfutqdfdvm2a...oduction.aspx),
have the jsp side parse out the session id and keep it around while
the user does what they need to do on the jsp pages, and then when it
is time to return to the ASP.Net side just construct a url that has
the cookieless session format with the same session id.

This works OK, but cookieless sessions have some limitations (e.g.
must use only relative addressing). Is there any other way that I can
recapture a session when I return to an asp.net page where I formerly
had a session just moments before? This is all required because I need
to capture that session_end event. It would be great if I could just
pass around a sessionid in the query string and create a session with
that specified id, but that doesn't appear to be possible.

Thanks.

May 18 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
You don't need to maintain the Session to ensure that the Session_End event
fires. The Session_End Event will fire as soon as the Session times out on
the server. It is a server-side event that happens without any interaction
with the client. The only part that the client has in terms of Session_End
is keeping the Session alive. The Session is on a timer, and when the timer
elapses, the Session_End event fires. When a Request from the same client
comes back, the timer is reset.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Marcus" <ho**********@hotmail.comwrote in message
news:11**********************@u30g2000hsc.googlegr oups.com...
>I have an ASP.Net 2.0 app that needs to jump out onto another web
server running a java server page website (Apache TomCat 4.1.12) that
I control. I hate that it needs to do this, but we are using some
internet GIS mapping web tool that comes "precanned" with lots of
mapping ability and its pages run on JSP. Theasp.net Session_End event
is quite important to catch as there is a lot of cleanup that needs to
happen in the database relating to the user of that session. Thus, I
need to maintain the session across ASP.Net and JSP webservers. A
hackish way that I accomplished this was to use cookieless sessions
which embeds the session id in the url (e.g.
http://www.abc.com/(S(2zmfutqdfdvm2a...oduction.aspx),
have the jsp side parse out the session id and keep it around while
the user does what they need to do on the jsp pages, and then when it
is time to return to the ASP.Net side just construct a url that has
the cookieless session format with the same session id.

This works OK, but cookieless sessions have some limitations (e.g.
must use only relative addressing). Is there any other way that I can
recapture a session when I return to an asp.net page where I formerly
had a session just moments before? This is all required because I need
to capture that session_end event. It would be great if I could just
pass around a sessionid in the query string and create a session with
that specified id, but that doesn't appear to be possible.

Thanks.

May 18 '07 #2

P: n/a
On May 18, 6:00 pm, Marcus <holysmoke...@hotmail.comwrote:
This works OK, but cookieless sessions have some limitations (e.g.
must use only relative addressing). Is there any other way that I can
recapture a session when I return to an asp.net page where I formerly
had a session just moments before? This is all required because I need
hmm. but what about "normal" cookie-based session?

May 18 '07 #3

P: n/a
Well, the thing is, when I leave the asp.net page and head over to
jsp, I loose the asp.net session. When I come back to the asp.net
page, I want to reestablish that same session so that the session_end
event will be raised only after this reestablished session has timed
out, not after a certain timeout period from when I first left the
asp.net page. There is a lot of user data in the database that both
the asp and jsp sides are accessing. When the session expires, I want
to remove this data. I have the cleanup code in the session_end event,
but if I can't reestablish the session, then the user data will be
removed prematurely.

One approach I might try is to record in the database the last access
time for a particular user for the site (thus for each page load this
would be updated). Then I could create a job in Sql Server that runs
every few minutes that does the data cleanup for the user once a
particular amount of time has passed from the last page access to the
current time.

M.

On May 18, 10:14 am, "Kevin Spencer" <unclechut...@nothinks.com>
wrote:
You don't need to maintain the Session to ensure that the Session_End event
fires. The Session_End Event will fire as soon as the Session times out on
the server. It is a server-side event that happens without any interaction
with the client. The only part that the client has in terms of Session_End
is keeping the Session alive. The Session is on a timer, and when the timer
elapses, the Session_End event fires. When a Request from the same client
comes back, the timer is reset.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net

"Marcus" <holysmoke...@hotmail.comwrote in message

news:11**********************@u30g2000hsc.googlegr oups.com...
I have an ASP.Net 2.0 app that needs to jump out onto another web
server running a java server page website (Apache TomCat 4.1.12) that
I control. I hate that it needs to do this, but we are using some
internet GIS mapping web tool that comes "precanned" with lots of
mapping ability and its pages run on JSP. Theasp.net Session_End event
is quite important to catch as there is a lot of cleanup that needs to
happen in the database relating to the user of that session. Thus, I
need to maintain the session across ASP.Net and JSP webservers. A
hackish way that I accomplished this was to use cookieless sessions
which embeds the session id in the url (e.g.
http://www.abc.com/(S(2zmfutqdfdvm2a...oduction.aspx),
have the jsp side parse out the session id and keep it around while
the user does what they need to do on the jsp pages, and then when it
is time to return to the ASP.Net side just construct a url that has
the cookieless session format with the same session id.
This works OK, but cookieless sessions have some limitations (e.g.
must use only relative addressing). Is there any other way that I can
recapture a session when I return to an asp.net page where I formerly
had a session just moments before? This is all required because I need
to capture that session_end event. It would be great if I could just
pass around a sessionid in the query string and create a session with
that specified id, but that doesn't appear to be possible.
Thanks.

May 18 '07 #4

P: n/a
I would prefer cookie based sessions, but still how do I re-establish
the session once I return to the asp.net page? It would be great if I
could assign the old session id (which would likely still be active)
to the new session object, but I don't think that is possible.

M.

On May 18, 10:51 am, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On May 18, 6:00 pm, Marcus <holysmoke...@hotmail.comwrote:
This works OK, but cookieless sessions have some limitations (e.g.
must use only relative addressing). Is there any other way that I can
recapture a session when I return to an asp.net page where I formerly
had a session just moments before? This is all required because I need

hmm. but what about "normal" cookie-based session?

May 18 '07 #5

P: n/a
On May 18, 8:46 pm, Marcus <holysmoke...@hotmail.comwrote:
I would prefer cookie based sessions, but still how do I re-establish
the session once I return to the asp.net page? It would be great if I
could assign the old session id (which would likely still be active)
to the new session object, but I don't think that is possible.
A session will expire when the time specified by the timeout passes
without a request being made for the session. And you can go to
another server and go back and get the session back during the time of
timeout. If you don't know what timeout you will need and to ensure
availability, a session can be extended by request (e.g. by a time
based javascript).

As I understand, the main problem is in the cache of user data in the
database. You shouldn't use the Session_End event to clean it up
(because it does not always fire), you need to make a job in Sql
Server. But here, I guess, will a problem that you don't know if you
can delete the cache or not...

Another approach can be a SQL Server mode session, that stores a
session in a SQL Server database. In this case, I think you can find
the time when the session has been updated.

May 18 '07 #6

P: n/a
That's an idea. A database is about the only thing you can count on. You can
store a unique identifier in the user's Cookies, which can be used to hook
the user back up to their cached data.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Marcus" <ho**********@hotmail.comwrote in message
news:11**********************@w5g2000hsg.googlegro ups.com...
Well, the thing is, when I leave the asp.net page and head over to
jsp, I loose the asp.net session. When I come back to the asp.net
page, I want to reestablish that same session so that the session_end
event will be raised only after this reestablished session has timed
out, not after a certain timeout period from when I first left the
asp.net page. There is a lot of user data in the database that both
the asp and jsp sides are accessing. When the session expires, I want
to remove this data. I have the cleanup code in the session_end event,
but if I can't reestablish the session, then the user data will be
removed prematurely.

One approach I might try is to record in the database the last access
time for a particular user for the site (thus for each page load this
would be updated). Then I could create a job in Sql Server that runs
every few minutes that does the data cleanup for the user once a
particular amount of time has passed from the last page access to the
current time.

M.

On May 18, 10:14 am, "Kevin Spencer" <unclechut...@nothinks.com>
wrote:
>You don't need to maintain the Session to ensure that the Session_End
event
fires. The Session_End Event will fire as soon as the Session times out
on
the server. It is a server-side event that happens without any
interaction
with the client. The only part that the client has in terms of
Session_End
is keeping the Session alive. The Session is on a timer, and when the
timer
elapses, the Session_End event fires. When a Request from the same client
comes back, the timer is reset.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net

"Marcus" <holysmoke...@hotmail.comwrote in message

news:11**********************@u30g2000hsc.googleg roups.com...
>I have an ASP.Net 2.0 app that needs to jump out onto another web
server running a java server page website (Apache TomCat 4.1.12) that
I control. I hate that it needs to do this, but we are using some
internet GIS mapping web tool that comes "precanned" with lots of
mapping ability and its pages run on JSP. Theasp.net Session_End event
is quite important to catch as there is a lot of cleanup that needs to
happen in the database relating to the user of that session. Thus, I
need to maintain the session across ASP.Net and JSP webservers. A
hackish way that I accomplished this was to use cookieless sessions
which embeds the session id in the url (e.g.
http://www.abc.com/(S(2zmfutqdfdvm2a...oduction.aspx),
have the jsp side parse out the session id and keep it around while
the user does what they need to do on the jsp pages, and then when it
is time to return to the ASP.Net side just construct a url that has
the cookieless session format with the same session id.
This works OK, but cookieless sessions have some limitations (e.g.
must use only relative addressing). Is there any other way that I can
recapture a session when I return to an asp.net page where I formerly
had a session just moments before? This is all required because I need
to capture that session_end event. It would be great if I could just
pass around a sessionid in the query string and create a session with
that specified id, but that doesn't appear to be possible.
Thanks.


May 18 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.