473,503 Members | 10,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET - get rid of Session variables when done

We have numerous pages that store datasets in Session. Sometimes these are
used for one page, sometimes for a few (ex. - search page looks up your info,
edit person page edits that info)

What i'd like is a way to get rid of these session variables when we no
longer need them. We originally trie putting cleanup code in Unload but then
realized unload gets called after every page hit, including postbacks, so it
wipes out data the active page is still using. That's not good

So not unload. Is there an event that tells me when the user is leaving this
page/URL for a different one? Then i could manually write the unload then

Alternately, is there a better way to do this?

My original idea was to use a FSM/workflow manager and have that control the
lifecycle of the session variables but we're near the end of the project and
don't really have time to implement that

Thanks

-baylor
Jul 22 '05 #1
2 1747
btw, since i want the life cyle of these TDSes to be similar to the data in
view state, an obvious solution would be to put the datasets in viewstate
(assuming i knew how, which i haven't given much thought to). The issue is
that some of these TDSes are large and so i don't picture that approach as
being very efficient

-b
Jul 22 '05 #2
I dunno about efficiency, but you could access your page's viewstate via
protected virtual StateBag ViewState, inherited from Control. You
could access this as an ordinary dictionary.

I havn't built anything similar, but I would probably save my serialized
object in a database, and store an id in viewstate. Run a stored
procedure on an interval to remove any object that isn't in use. This
system could easily be expanded to a generic object cache storage. ;)

baylor wrote:
btw, since i want the life cyle of these TDSes to be similar to the data in
view state, an obvious solution would be to put the datasets in viewstate
(assuming i knew how, which i haven't given much thought to). The issue is
that some of these TDSes are large and so i don't picture that approach as
being very efficient

-b

Jul 22 '05 #3

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

Similar topics

9
3628
by: Pack Fan | last post by:
I've noticed that session variables will persist on Mac IE even after all browser windows have been closed. One must quit the program to clear the session variables. This presents a security risk...
1
3096
by: Ann Leland | last post by:
I have been using session variables to pass a user name from one ASP page to another inside framesets for 9 months and it stopped working this week. I have made no code changes but there was a...
14
1851
by: qaz | last post by:
I've always used session cookies in my web sites. However, since more and more people (including me) are starting to disable cookies, I'm beginning to think that I should change my ways and design...
3
7107
by: JezB | last post by:
I want to clear some specific Session variables when the user closes a page. On my page I have a "return to ..." button which navigates back to the parent page from which it was invoked - under the...
1
3160
by: Steve Remer | last post by:
My application (relevant code snippets below) originally used Session variables in order to maintain state from page to page. After being unable to solve the mystery of why those variables were...
4
1745
by: abcd | last post by:
I have an ASP application. It instantiaties some COM components and we put those COM components in Session variables...COM components have license restrictions...We have written new ASPX page ( for...
3
2664
by: Phillip N Rounds | last post by:
I'm writing a user control which has two states: Active & InActive. I additionally am required that there to be only one active control per page, and all logic has to be contained within the...
5
3166
by: Ed | last post by:
I have some questions in regards to Session variables and IIS Recycling: 1. Does the IIS setting 'Shutdown worker process after being idle' affect an application's session variables? Or is IIS...
26
3576
by: BillE | last post by:
Some ASP.NET applications use Session Variables extensively to maintain state. These should be re-written to use viewstate, hidden fields, querystring, etc. instead. This is because if a user...
6
3752
by: ChrisAtWokingham | last post by:
I have been struggling with unexpected error messages on an ASP.NET system, using SQL and C#. The application draws organisation charts, based on data stored in the SQL database. Some of the chart...
0
7361
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...
1
7015
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5602
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,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4693
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...
0
3183
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...
1
749
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
403
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...

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.