Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Global Objects in ASP.NET

Global Objects in ASP.NET

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-netxmljson
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    triton630
    wrote on last edited by
    #1

    Hi, I have small web application that loads some data from an XML file based on a client code entered. I've created an class with some methods for parsing out certain information at certain points within the application. Right now I am creating this object whenever I need it and setting some required information (client code, xml file name) and then calling the method I need. Is there a way to load the object when the user logs in for the life of the application? Would I do this in the global.asax? I guess the other question is now that I'm writing this out, would that be for the life of the session? or application? Thanks in advance.

    C R 2 Replies Last reply
    0
    • T triton630

      Hi, I have small web application that loads some data from an XML file based on a client code entered. I've created an class with some methods for parsing out certain information at certain points within the application. Right now I am creating this object whenever I need it and setting some required information (client code, xml file name) and then calling the method I need. Is there a way to load the object when the user logs in for the life of the application? Would I do this in the global.asax? I guess the other question is now that I'm writing this out, would that be for the life of the session? or application? Thanks in advance.

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      triton630 wrote: Is there a way to load the object when the user logs in for the life of the application? Would I do this in the global.asax? Be careful with the use of the word "application" in reference to ASP.NET. A web application spans all sessions and all users. What you are probably wanting to do is to store the information in the Session oject. And yes, you could put this in the global.asax (in Session Start). triton630 wrote: would that be for the life of the session? The session last as long as the timeout set in the <sessionState> element in the web.config file. Well, actually the session last longer than that as each page request keeps the session alive. triton630 wrote: or application? The application starts on the first page request. Also (excerpt from MSDN)... When you save changes to an active Global.asax file, the ASP.NET page framework detects that the file has been changed. It completes all current requests for the application, sends the Application_OnEnd event to any listeners, and restarts the application domain. In effect, this reboots the application, closing all browser sessions and flushing all state information. When the next incoming request from a browser arrives, the ASP.NET page framework reparses and recompiles the Global.asax file and raises the Application_OnStart event. Otherwise, AFAIK, the application will keep going until IIS is shut down.


      Do you want to know more?

      R 1 Reply Last reply
      0
      • C Colin Angus Mackay

        triton630 wrote: Is there a way to load the object when the user logs in for the life of the application? Would I do this in the global.asax? Be careful with the use of the word "application" in reference to ASP.NET. A web application spans all sessions and all users. What you are probably wanting to do is to store the information in the Session oject. And yes, you could put this in the global.asax (in Session Start). triton630 wrote: would that be for the life of the session? The session last as long as the timeout set in the <sessionState> element in the web.config file. Well, actually the session last longer than that as each page request keeps the session alive. triton630 wrote: or application? The application starts on the first page request. Also (excerpt from MSDN)... When you save changes to an active Global.asax file, the ASP.NET page framework detects that the file has been changed. It completes all current requests for the application, sends the Application_OnEnd event to any listeners, and restarts the application domain. In effect, this reboots the application, closing all browser sessions and flushing all state information. When the next incoming request from a browser arrives, the ASP.NET page framework reparses and recompiles the Global.asax file and raises the Application_OnStart event. Otherwise, AFAIK, the application will keep going until IIS is shut down.


        Do you want to know more?

        R Offline
        R Offline
        Rocky Moore
        wrote on last edited by
        #3

        Actually, under default settings for IIS in Windows 2003, the application is killed after (x) amount of idle time for clean up. If you do not changes it settings and you have little traffic to the site, many users may actually have a long wait when they first hit your site due to the applications and everything loading and running. With my busy sites, I force them to cycle at 3:00 AM every day and not allow the recycling to occur which keeps the site lively and still allows for cleanup and my slow time of the day. Rocky <>< www.HintsAndTips.com - Now with "Recommendation" postings www.JokesTricksAndStuff.com www.MyQuickPoll.com - Now with RSS Feed and Prizes www.GotTheAnswerToSpam.com - Again :)

        1 Reply Last reply
        0
        • T triton630

          Hi, I have small web application that loads some data from an XML file based on a client code entered. I've created an class with some methods for parsing out certain information at certain points within the application. Right now I am creating this object whenever I need it and setting some required information (client code, xml file name) and then calling the method I need. Is there a way to load the object when the user logs in for the life of the application? Would I do this in the global.asax? I guess the other question is now that I'm writing this out, would that be for the life of the session? or application? Thanks in advance.

          R Offline
          R Offline
          Rocky Moore
          wrote on last edited by
          #4

          It sounds more like you want a session object Session["MyVariable"]=myobject; You might also look into the "cache", as you can cache an object so that it will stay around until you do not need it unless memory is low and it needs to clear it out at which time it can notify you so that you can refresh the ojbect. This allows you to normally build and set the object once, but if things are running tight, it will still be able to reclaim that memory until you need the object again. If you should happen to have information that is global to all users, such as maybe a category list that does not normally change, you can read those in at the start of your app and simply store them in your Application storage: Application["MyVariable"]=myobject; The application store can also be locked when doing updates so that no collisions occur. Rocky <>< www.HintsAndTips.com - Now with "Recommendation" postings www.JokesTricksAndStuff.com www.MyQuickPoll.com - Now with RSS Feed and Prizes www.GotTheAnswerToSpam.com - Again :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups