Newbie question ( global variable definition page? )

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

in my series of asp.net c# pages, I wish to create one
page that will just contain various variables. Similar to
the application.cfm page in coldfusion. how is this done?
 
From the Global.asax file, you can assign key/value items to the Application
or Session (please excuse the VB, I'm unfamiliar with C# syntax)

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
'If you change this, you change it for everyone
Application.Add("EveryonesPie", 3.14)
End Sub

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
'If you change this, you change it for this particual user's session
Session.Add("ThisUsersPie", 3.14)
End Sub

Then reference them wherever you need to:

myPie = Session.Item("ThisUsersPie")
theirPie = Application.Item("EveryonsPie")
 
Back
Top