Global.asax and Web.Config

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

I've created an <appSettings> variable called "AppStartTime". Within the
Global.asax file in the Application_Start procedure I want to set the
"AppStartTime" to the current time. How can I access this variable in the
Global.asax file and set or read it's value? I know how to do it in a regular
..aspx.cs file, but not in the Global.asax file.
 
Hi.

I can read the keys from Global.asax using:
string key = ConfigurationManager.AppSettings["key"];

Tommy.
 
I've created an <appSettings> variable called "AppStartTime". Within the
Global.asax file in the Application_Start procedure I want to set the
"AppStartTime" to the current time. How can I access this variable in the
Global.asax file and set or read it's value? I know how to do it in a regular
.aspx.cs file, but not in the Global.asax file.

IIRC It's read only.
What ou can do is store the value in either Session or Application
scope.
 
Greg said:
I've created an <appSettings> variable called "AppStartTime". Within the
Global.asax file in the Application_Start procedure I want to set the
"AppStartTime" to the current time. How can I access this variable in the
Global.asax file and set or read it's value? I know how to do it in a
regular
.aspx.cs file, but not in the Global.asax file.

Modifing the WebConfig cause the application to restart. Hence if you
modify the web.config during application start you going to create an
infinite loop.

Web.Config is not the place to store this sort of info. Record it in
another xml or txt file or record it in a DB.
 
Back
Top