473,796 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FileSystemWatch er 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 SystemFileWatch er 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_Sta rt call in Global.ascx. All works fine until the file
changes..

Because the filesystemWatch er 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 OnConfiguration Changed(object sender, FileSystemEvent Args
e) {
MenuContainer container =
(MenuContainer) HttpContext.Cur rent.Applicatio n["SubMenu"];

container.LoadC onfiguration();

HttpContext.Cur rent.Applicatio n["SubMenu"] = container;
}

Mar 13 '06 #1
3 1380
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
15892
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 mechanism in PHP?
3
1992
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 "Visitor: " & Application("VisitorCount") %>
0
332
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 Server and an assembly I built that I published inthe GAC. It's a service component and runs as a ServerApplication in Component Services under a particular identityinstead of the identity of the application that is calling it. I use the object...
1
1243
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 some way to peek in the data of these sessions. If there is no such utility for IIS, perhaps there is some API that I could use to write a standalone console .NET EXE, that could talk to IIS (or some other relevant instance) and discover these...
20
4499
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 logic layer(so far so good and easy).I initialize my class which is using a FileSystemWatcher in my Global.asax and everything works fine.I have found FileSystemWatcher class not very reliable and sometimes it behavies unexpectedly.I'm afriad that...
5
1993
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 Singleton() { } public static Singleton getInstance()
3
4794
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 application settings in Visual Studio (right-click on the project, go to the settings tab, etc.) and have associated each of these settings with a property on a form. This seems to be working right (i.e. if I edit the default value of a setting,...
5
5607
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, monitors a folder and then returns the contents of the new/changed files. However, if the client app loses connection to the webservice without closing the filewatcher, and then reconnects (and thus creates a new watcher), I believe I end up with...
2
1008
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
10244
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10201
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9061
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6802
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5454
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4130
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.