FileSystemWatcher and Application Scoped session

R

rgparkins

HI

I have an ASp.NET web application that I am developing which uses a
menu control that will not change "very frequently" BUT can do!. The
control will load its menu items from an xml file that exists in a
configuration directory.

My idea was to have a SystemFileWatcher which is notified when the file
changes. This will in turn load the new config into the Application
object on the server. The user control ALWAYS loads its config through
the Application object.

My idea was to set the config within the Application object within the
Application_Start call in Global.ascx. All works fine until the file
changes..

Because the filesystemWatcher event is generated outside the
application scope it has no reference to the Application object
therefore cannot update it..

Its more than likely my understanding of this area of ASP.NET, but can
you pass the event the context of the application so I can update the
Application scoped variable for the menu usercontrol?

Perhaps a delegate? or maybe this is overkill and I should go for the
Cache object but wanted to explore this area as obviously if no file
changes are done then no processing is done:)

If any one can shine some light or point me in some kind of direction I
would be interested to hear your advice. My Event handler below:

Many thanks

Richard

private void OnConfigurationChanged(object sender, FileSystemEventArgs
e) {
MenuContainer container =
(MenuContainer)HttpContext.Current.Application["SubMenu"];

container.LoadConfiguration();

HttpContext.Current.Application["SubMenu"] = container;
}
 
R

rgparkins

Hi Darren.. Fantastic.. exactly what I was looking for...

Many thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top