471,339 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,339 software developers and data experts.

Global.asax and Web.Config

I've created an <appSettingsvariable 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.
Sep 16 '08 #1
3 5323
Hi.

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

Tommy.

On Tue, 16 Sep 2008 10:54:01 -0700, Greg <Ac**********@newsgroups.nospamwrote:
>I've created an <appSettingsvariable 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.
Sep 16 '08 #2
On Sep 16, 1:54*pm, Greg <AccessVBA...@newsgroups.nospamwrote:
I've created an <appSettingsvariable 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.
Sep 16 '08 #3

"Greg" <Ac**********@newsgroups.nospamwrote in message
news:68**********************************@microsof t.com...
I've created an <appSettingsvariable 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.

--
Anthony Jones - MVP ASP/ASP.NET

Sep 16 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Mark | last post: by
6 posts views Thread by Andrea Williams | last post: by
3 posts views Thread by hansiman | last post: by
22 posts views Thread by fd123456 | last post: by
12 posts views Thread by John M | last post: by
8 posts views Thread by Vishwanathan Raman | last post: by
1 post views Thread by Anonieko | last post: by
1 post views Thread by teo | last post: by
5 posts views Thread by Eric Layman | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.