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. Initializing ASP.NET

Initializing ASP.NET

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-net
8 Posts 5 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.
  • Y Offline
    Y Offline
    Yoyosch
    wrote on last edited by
    #1

    I would like to call some methods at the very beginning of my web application. Also, I want to ensure that those methods are called only once per application lifetime, no matter what. What is the best way to accomplish this?

    M B A J 4 Replies Last reply
    0
    • Y Yoyosch

      I would like to call some methods at the very beginning of my web application. Also, I want to ensure that those methods are called only once per application lifetime, no matter what. What is the best way to accomplish this?

      M Offline
      M Offline
      Morgs Morgan
      wrote on last edited by
      #2

      TRY THIS

      protected void Page_Load(object sender, EventArgs e)
      {
      if(!IsPostBack)
      {
      FillConatcsGrid();//fills you contacts datagrid only once
      CheckSessionId();//Will check the session id if need be only once
      //Then you can go ahead with more fun in here...
      }
      }

      GoodLuck

      Y 1 Reply Last reply
      0
      • Y Yoyosch

        I would like to call some methods at the very beginning of my web application. Also, I want to ensure that those methods are called only once per application lifetime, no matter what. What is the best way to accomplish this?

        B Offline
        B Offline
        Brij
        wrote on last edited by
        #3

        If your methods are Application specific, and wiil be same for all then users then you can call your methopds from the function Application_Start of Global.asax file. and if it user specific then you can call your methopds from the function Session_Start of Global.asax file.

        Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

        Y 1 Reply Last reply
        0
        • M Morgs Morgan

          TRY THIS

          protected void Page_Load(object sender, EventArgs e)
          {
          if(!IsPostBack)
          {
          FillConatcsGrid();//fills you contacts datagrid only once
          CheckSessionId();//Will check the session id if need be only once
          //Then you can go ahead with more fun in here...
          }
          }

          GoodLuck

          Y Offline
          Y Offline
          Yoyosch
          wrote on last edited by
          #4

          This will not work as user may start my application from different page

          1 Reply Last reply
          0
          • Y Yoyosch

            I would like to call some methods at the very beginning of my web application. Also, I want to ensure that those methods are called only once per application lifetime, no matter what. What is the best way to accomplish this?

            A Offline
            A Offline
            Avinash_Mane
            wrote on last edited by
            #5

            You can use methods of Global.asax file see help of Global.asax file in google

            1 Reply Last reply
            0
            • B Brij

              If your methods are Application specific, and wiil be same for all then users then you can call your methopds from the function Application_Start of Global.asax file. and if it user specific then you can call your methopds from the function Session_Start of Global.asax file.

              Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

              Y Offline
              Y Offline
              Yoyosch
              wrote on last edited by
              #6

              Tnx, it was exactly what I asked for. Thank you

              B 1 Reply Last reply
              0
              • Y Yoyosch

                Tnx, it was exactly what I asked for. Thank you

                B Offline
                B Offline
                Brij
                wrote on last edited by
                #7

                your welcome :)

                Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

                1 Reply Last reply
                0
                • Y Yoyosch

                  I would like to call some methods at the very beginning of my web application. Also, I want to ensure that those methods are called only once per application lifetime, no matter what. What is the best way to accomplish this?

                  J Offline
                  J Offline
                  Jamil Hallal
                  wrote on last edited by
                  #8

                  The Global.asax file is the central point for ASP.NET applications. It provides numerous events to handle various application-wide tasks such as user authentication, application start up, and dealing with user sessions.The Global.asax file, which is derived from the HttpApplication class, maintains a pool of HttpApplication objects, and assigns them to applications as needed. The Global.asax file contains the following event: Application_Start : Fired when the first instance of the HttpApplication class is created. It allows you to create objects that are accessible by all HttpApplication instances. you can use this event it to perform the actions you wanted.

                  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