Click here to Skip to main content
16,007,163 members
Home / Discussions / C#
   

C#

 
GeneralUsing Resource file for collection of strings Pin
Inpreet Singh16-Mar-04 0:32
Inpreet Singh16-Mar-04 0:32 
GeneralRe: Using Resource file for collection of strings Pin
Heath Stewart16-Mar-04 3:42
protectorHeath Stewart16-Mar-04 3:42 
GeneralRe: Using Resource file for collection of strings Pin
Inpreet Singh16-Mar-04 23:17
Inpreet Singh16-Mar-04 23:17 
GeneralRe: Using Resource file for collection of strings Pin
Heath Stewart17-Mar-04 3:26
protectorHeath Stewart17-Mar-04 3:26 
QuestionWindows Service + ASP.NET, HOW? Pin
Johnny_B15-Mar-04 23:18
Johnny_B15-Mar-04 23:18 
AnswerRe: Windows Service + ASP.NET, HOW? Pin
Heath Stewart16-Mar-04 3:35
protectorHeath Stewart16-Mar-04 3:35 
GeneralRe: Windows Service + ASP.NET, HOW? Pin
Werdna16-Mar-04 4:02
Werdna16-Mar-04 4:02 
GeneralRe: Windows Service + ASP.NET, HOW? Pin
Heath Stewart16-Mar-04 4:15
protectorHeath Stewart16-Mar-04 4:15 
No, not easily (and do I mean HARD, since it would require using Directory Service Objects (DSO) to get the application and a bunch of other code to get the ApplicationState). The easiest thing to do is to handle the Application.Start event (already hooked-up for you in your Global.asax or Global.asax.cs file) and query to get data for the application, whether that comes from a database or what. If you need to change this at runtime, another way would be to use a file (say, for example, an XML file) and store that in a cache object with a CacheDependency so that when you change the file the cache is invalidated and the data would be read next time, something like:
protected void Application_Start(object sender, EventArgs e)
{
  // While the cache is a singleton, you can still only get it from the
  // current request context.
  HttpContext current = HttpContext.Current;
  if (current != null)
  {
    Cache cache = current.Cache;
    XmlDocument doc = cache["MyStuff"];
    if (doc == null)
    {
      // Not cached (or has been invalidated) - reload it.
      doc = new XmlDocument();
      string path = Server.MapPath("/data/mystuff.xml");
      doc.Load(path);
      cache.Add("MyStuff", doc, new CacheDependency(path),
        Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,
        CacheItemPriority.High, null);
    }
    // Do something with "doc" now.
  }
}
There's many other ways you can accomplish something like this without using services or remoting too.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Windows Service + ASP.NET, HOW? Pin
Johnny_B16-Mar-04 13:11
Johnny_B16-Mar-04 13:11 
GeneralRe: Windows Service + ASP.NET, HOW? Pin
Heath Stewart17-Mar-04 4:58
protectorHeath Stewart17-Mar-04 4:58 
QuestionHow to read records of a file of dbf in c# ? Pin
Solaer15-Mar-04 23:06
Solaer15-Mar-04 23:06 
Generalmain []args parameter to run another instance Pin
hazzem elrefai15-Mar-04 22:57
hazzem elrefai15-Mar-04 22:57 
GeneralRe: main []args parameter to run another instance Pin
hazzem elrefai16-Mar-04 1:41
hazzem elrefai16-Mar-04 1:41 
GeneralDrag and Drop feature in TreeView Pin
viru15-Mar-04 21:04
viru15-Mar-04 21:04 
GeneralRe: Drag and Drop feature in TreeView Pin
Heath Stewart16-Mar-04 3:23
protectorHeath Stewart16-Mar-04 3:23 
GeneralWeb control questions Pin
Den2Fly15-Mar-04 19:55
Den2Fly15-Mar-04 19:55 
GeneralRe: Web control questions Pin
Heath Stewart16-Mar-04 3:19
protectorHeath Stewart16-Mar-04 3:19 
GeneralRe: Web control questions Pin
Den2Fly16-Mar-04 3:44
Den2Fly16-Mar-04 3:44 
GeneralRe: Web control questions Pin
Heath Stewart16-Mar-04 3:53
protectorHeath Stewart16-Mar-04 3:53 
GeneralThank you so much -nt Pin
Den2Fly16-Mar-04 4:53
Den2Fly16-Mar-04 4:53 
GeneralDoubleBuffer Exception Pin
Amberite0015-Mar-04 16:40
Amberite0015-Mar-04 16:40 
GeneralRe: DoubleBuffer Exception Pin
John Fisher15-Mar-04 17:08
John Fisher15-Mar-04 17:08 
GeneralRe: DoubleBuffer Exception Pin
Amberite0015-Mar-04 17:32
Amberite0015-Mar-04 17:32 
GeneralRe: DoubleBuffer Exception Pin
John Fisher16-Mar-04 12:49
John Fisher16-Mar-04 12:49 
GeneralRe: DoubleBuffer Exception Pin
Heath Stewart16-Mar-04 3:15
protectorHeath Stewart16-Mar-04 3:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.