473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 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 5577
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark | last post by:
I have two projects - they both need to use the same web.config file, the same global.asax file, and share a common "look and feel" via several user controls. Is there an easy way for two...
6
by: Andrea Williams | last post by:
Where is the best place to put global variables. In traditional ASP I used to put all of them into an include file and include it in every page. Will the Global.aspx.cs do that same thing? ...
3
by: hansiman | last post by:
I use Application_Start in global.asax to set some physical folder paths ie.: Application("pdf") = "c:\www\<site>\pdf\" global.asax uses code behind. When I move the project from the dev to...
22
by: fd123456 | last post by:
Hi Tom ! Sorry about the messy quoting, Google is playing tricks on me at the moment. > Global.asax is where you normally have the Global Application > and Session variables and code to...
12
by: John M | last post by:
Hello, On Microsoft Visual Studio .NET 2003, I want to use some global elements, that can be used in each one of my pages. i.e I put a oleDBConnection on global.asax.vb How can I use it...
8
by: Vishwanathan Raman | last post by:
Hi I have a declared a static DataSet object SOBJ in Global.asax.I also have a localy defined DataSet LSOBJ in Global.asax which I am storing in Application State.Is there any technical...
1
by: Anonieko | last post by:
Global.asax? Use HttpModules Instead! In a previous post, I talked about HttpHandlers - an underused but incredibly useful feature of ASP.NET. Today I want to talk about HttpModules, which are...
8
by: Doug | last post by:
Visual Studio 2005, SQL Server 2000, ASP.NET/VB.NET Not allowed to use the ASPNET machine account in SQL Server (very strict environment). Need to use Windows authentication, so we use...
1
by: teo | last post by:
I put some variables in a web.config file I have a global.asax file that needs to use one of those variables How can global.asax read that value? If I have more than one web.config ...
5
by: Eric Layman | last post by:
Hi everyone, Currently Im using Global.asax.vb to capture any errors and to send them via email to me. But I didn't get any emails when I purposely crash the web application. May I know what...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.