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;
}
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;
}