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. How to access global.asax values in class file

How to access global.asax values in class file

Scheduled Pinned Locked Moved ASP.NET
csharphelptutorial
5 Posts 2 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.
  • K Offline
    K Offline
    kandalu
    wrote on last edited by
    #1

    Hi, I am using .net 2.0. I created a class file "condb.cs" in my website. I declared a variable in Globale.asax. I can access that value in first.aspx.cs page and i can't access that value in condb.cs file. Please help me to retrieve the global value in .cs file. Thanks.

    C 1 Reply Last reply
    0
    • K kandalu

      Hi, I am using .net 2.0. I created a class file "condb.cs" in my website. I declared a variable in Globale.asax. I can access that value in first.aspx.cs page and i can't access that value in condb.cs file. Please help me to retrieve the global value in .cs file. Thanks.

      C Offline
      C Offline
      Caio Kinzel Filho
      wrote on last edited by
      #2

      Why not to use application variables? like: Application[key] = value;

      Intelligence is almost useless for those who have nothing else! Email: caiokf@gmail.com

      K 1 Reply Last reply
      0
      • C Caio Kinzel Filho

        Why not to use application variables? like: Application[key] = value;

        Intelligence is almost useless for those who have nothing else! Email: caiokf@gmail.com

        K Offline
        K Offline
        kandalu
        wrote on last edited by
        #3

        Hi, Application variables can be used in aspx.cs files only. I have to access it in a separate .cs file. So, now I used HttpContext to access that global variable. If you know some other methods for that please refer me. Thanks.

        C 1 Reply Last reply
        0
        • K kandalu

          Hi, Application variables can be used in aspx.cs files only. I have to access it in a separate .cs file. So, now I used HttpContext to access that global variable. If you know some other methods for that please refer me. Thanks.

          C Offline
          C Offline
          Caio Kinzel Filho
          wrote on last edited by
          #4

          Application variables can be accessed in separate .cs files using: HttpContext.Current.Application[key]

          Intelligence is almost useless for those who have nothing else! Email: caiokf@gmail.com

          K 1 Reply Last reply
          0
          • C Caio Kinzel Filho

            Application variables can be accessed in separate .cs files using: HttpContext.Current.Application[key]

            Intelligence is almost useless for those who have nothing else! Email: caiokf@gmail.com

            K Offline
            K Offline
            kandalu
            wrote on last edited by
            #5

            Hi, Thanks for your quick reply. I tried the method you have given. I got it right. Thanks.

            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