Solved

How to clean up page variables when user closes the web page?

Posted on 2015-01-07
4
115 Views
Last Modified: 2015-01-08
Hi, I'm using vs2012.
I have several variables declared under the page class, public partial class _Default : Page

What's the best way to dispose() or clean up these variables?  I tried accessing them from Global.asax.cs in the Applicaiton-End event but I wasn't able to access these variables when I type in namesapce._Default.  None of the variables show up.
How to clean these up?
Thank you.
0
Comment
Question by:lapucca
  • 2
  • 2
4 Comments
 
LVL 23

Expert Comment

by:Michael74
Comment Utility
If they are declared inside the page object then they should go out of scope and be destroyed when the page unloads but if you want to handle this yourself then use the Page.Unload event
http://msdn.microsoft.com/en-us/library/system.web.ui.control.unload(v=vs.110).aspx
0
 

Author Comment

by:lapucca
Comment Utility
These are variables/properties declare in the page object right after this loc
 public partial class _Default : Page

I have generic collection, about 20-100 objects. So would you recommend to let it go out of scope and garbage collector does its thing or calling the page.unload event to clean up? Thank you.
0
 
LVL 23

Accepted Solution

by:
Michael74 earned 500 total points
Comment Utility
.Net has pretty good GC algorithms and so unless it is unmanaged eg COM then I would the GC to the system and set the scope appropiately
0
 

Author Comment

by:lapucca
Comment Utility
Sounds good.  Thank you.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now