473,385 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

FileSystemWatcher and Application Scoped session

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

Mar 13 '06 #1
3 1359
Use the caching object. Look at the overloads Cache.Insert(), there is
an option to add a file dependancy such as your xml file. This means,
that when that xml file changes, the cached item will be thrown out and
regenerated. Just have your control handle the caching logic.

For more information on the insert method, check out
http://msdn.microsoft.com/library/de...serttopic2.asp

HTH,
Darren Kopp
http://blog.secudocs.com/

Mar 13 '06 #2
Hi Darren.. Fantastic.. exactly what I was looking for...

Many thanks for your help

Mar 13 '06 #3
Great, best of luck with your control.

Happy .NETing,
Darren Kopp
http://blog.secudocs.com/

Mar 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

33
by: aa | last post by:
I am migrating to PHP from ASP where there are the Application Scope variables which are accessible from any page on a website and which are used, in particular, for hit counters. Is there a similar...
3
by: Wayfarer | last post by:
Hi, I'm trying to set up a simple application-scoped counter in global.asa to display on my webpages. When I call Application("VisitorCount") on another page as shown: <% response.write...
0
by: Clifford Tillman via .NET 247 | last post by:
Hello all. I've noticed something curious when using a filesystem watcher and was wondering if anybody had experienced thesame thing. All of my web applications manage their sessionthrough SQL...
1
by: Pavils Jurjans | last post by:
Hello, I have a couple of unclear questions about ASP.NET sessions: First, I'd like to have some way to see how many sessions currently are running on the certain application, and, possibly, have...
20
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business...
5
by: Rich | last post by:
The following code produced a singleton object with application scope when it should have had page scope: public class Singleton { private static Singleton uniqueInstance = null; private...
3
by: xycos | last post by:
Hello. I apologize for asking this question as the information I need is availible via the MSDN library, however I cannot seemt o understand what I need to do, so I'm asking here. I have created...
5
by: =?Utf-8?B?Sm9obiBT?= | last post by:
I am trying to find out if there is a way to tell if there is already a filesystemwatcher (created by a webservice) monitoring a folder. I have a webservice that creates a filesystemwatcher,...
2
by: maciek kanski | last post by:
Hello Please help me grasp the idea of the following question: and the correct answer with explanation is: Maybe it's a problem with my understanding of the english language,
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.