Accessing Instance Class and Variables accross entire application

  • Thread starter Thread starter Juan Gabriel Del Cid
  • Start date Start date
J

Juan Gabriel Del Cid

I suppose a session variable may be an option, but that
seems less then ideal...

Why does that seem less than ideal? The session object is there to handle
session information. That is exactly what you want.

-JG
 
I am programming ASP.NET using C#.

I have been accessing static variables accross my entire application but now
need to change some of the static variables that are session specific to
instance variables.
(For more background, see previous post about 30 min ago)

It was so cool using static variables because they where global to the
entire application so I could calculate them when the page loaded and use
then anywhere in the app. Now I need to use instance variables so that there
will not be session conflicts but would still like to be able to access
those instance variables from anywhere. Is there a way of doing this?

Since my app always loads the same page and then loads user controls to
change pages, I can instance a class in the default.aspx page and set its
variables (properties or fields) for that page load. The question is how do
I make that instanced class and its members accessable to all other pages
within my application?

I suppose a session variable may be an option, but that seems less then
ideal...

Thanks for your help

Earl
 
I guess I was hoping for a C# language way of doing this rather then an
ASP.NET way since this is such a core part of the application. On thing I
don't like about using a session variable is that it holds the object in
memory until it times out at the set timeout interval. Instance objects, on
the other hand, are passed to the garbage collector or destruction as soon
as they go out of scope. This meens that they are not wasting resources
hanging around in memory. Maybe I should look into a way of destroying the
session object once the page has loaded???

I could use C# to pass the variables from method to method but this gets to
be a mess also. (tons of passing variables)

Earl
 
Back
Top