Hooking into Application objects

  • Thread starter Thread starter Brian Bender
  • Start date Start date
B

Brian Bender

I am trying to write a static utility class that allows me to modify
Application variables in my web application.

My problem is that I cannot figure out what to import or inherit to
allow me to see application objects or even the server object.

Here is my code:

Public Shared RefreshCachedXMLDatasets()

Dim dsLinks As New DataSet()
'-- Cached XML Menu
dsLinks = New DataSet()
dsLinks.ReadXml(Server.MapPath(Utilities.GetConfigValue("XMLMenuFilename",
"")))
Application("CACHED_XML_MENU") = dsLinks

'-- Cached Portfolio
dsLinks = New DataSet()
dsLinks.ReadXml(Server.MapPath(Utilities.GetConfigValue("XMLPortfolioFilename",
"")))
Application("CACHED_XML_PORTFOLIO") = dsLinks
End Sub

The application object or server object do not exsist.
Any Suggestions?
 
Hi Brian,

I would suggest implementing this class as an amended singleton. It would
have an Initialize method creating the sole instance which would accept the
Application object as the argument. This method would be called upon
Application_OnStart. Then, it would have the standard singleton Instance
property to access the sole instance. This instance will have been
pre-initialized with a reference to the application object by the moment you
will be accessing it for the first time.
 
Dmitriy,

I uderstand what you are saying. i am familiar with singleton. However
isn't there a built in way to do this. All webforms are classes and
they see these objects. How do they do it? It has got to be some type
of import or inheritance.
 
Back
Top