G
Guest
Hi,
i've written a class which does some calculations for my web application.
These informatinos are different for each page request - the current user is
not important.
i have about 10 aspx pages and 20 ascx user controls. In most of these
pages/user controls i need the informations of this class.
First i created an instance of this class in every page/user control i
needed the information with the result that a page with 10 usercontrols
calculated the same information 11 times until the request is completed
(=many redundant/identical calculations).
So i created a static public instance of this class in the global.asax
Application_PreRequestHandlerExecute event. The class is now created just
once per page request and i can access it from the page and usercontrols like
Global.MyClass.MyPoperties.
But i'm not happy with this because i'm getting "accidentally" errors like
"Object has been disposed" when i access properties of this class. The errors
occur on all thinkable usercontrols and pages. There is no special code
fragment which raise the error.
But this behavior occurs only if i the app has a very high load. (i
simulated this on my dev box with the application test center).
I searched for "global variables" to try another approach but i found
nothing really usefull.
Now i'm thinking of
a) using a session instead of a static to hold the instance of this class or
b) to create a instance of this class in the page_load/prerender event of a
all my pages and make this instance accessable to the usercontrols with a
property.
or c) i'm completly wrong all the time and there's another/better way to
access "global variables" accross a page and its usercontrols.
Any suggestions?
Thanks
i've written a class which does some calculations for my web application.
These informatinos are different for each page request - the current user is
not important.
i have about 10 aspx pages and 20 ascx user controls. In most of these
pages/user controls i need the informations of this class.
First i created an instance of this class in every page/user control i
needed the information with the result that a page with 10 usercontrols
calculated the same information 11 times until the request is completed
(=many redundant/identical calculations).
So i created a static public instance of this class in the global.asax
Application_PreRequestHandlerExecute event. The class is now created just
once per page request and i can access it from the page and usercontrols like
Global.MyClass.MyPoperties.
But i'm not happy with this because i'm getting "accidentally" errors like
"Object has been disposed" when i access properties of this class. The errors
occur on all thinkable usercontrols and pages. There is no special code
fragment which raise the error.
But this behavior occurs only if i the app has a very high load. (i
simulated this on my dev box with the application test center).
I searched for "global variables" to try another approach but i found
nothing really usefull.
Now i'm thinking of
a) using a session instead of a static to hold the instance of this class or
b) to create a instance of this class in the page_load/prerender event of a
all my pages and make this instance accessable to the usercontrols with a
property.
or c) i'm completly wrong all the time and there's another/better way to
access "global variables" accross a page and its usercontrols.
Any suggestions?
Thanks