473,785 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Global.asax and Web.Config

I've created an <appSettingsvar iable called "AppStartTi me". Within the
Global.asax file in the Application_Sta rt procedure I want to set the
"AppStartTi me" 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 5662
Hi.

I can read the keys from Global.asax using:
string key = ConfigurationMa nager.AppSettin gs["key"];

Tommy.

On Tue, 16 Sep 2008 10:54:01 -0700, Greg <Ac**********@n ewsgroups.nospa mwrote:
>I've created an <appSettingsvar iable called "AppStartTi me". Within the
Global.asax file in the Application_Sta rt procedure I want to set the
"AppStartTim e" 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...@n ewsgroups.nospa mwrote:
I've created an <appSettingsvar iable called "AppStartTi me". Within the
Global.asax file in the Application_Sta rt procedure I want to set the
"AppStartTi me" 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**********@n ewsgroups.nospa mwrote in message
news:68******** *************** ***********@mic rosoft.com...
I've created an <appSettingsvar iable called "AppStartTi me". Within the
Global.asax file in the Application_Sta rt procedure I want to set the
"AppStartTi me" 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
1979
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 projects to share these resources in VS.NET so we don't have to worry about synchronization issues ASIDE from combining the two projects into one? Thanks in advance! Mark
6
3633
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? Thanks in Advance! Andrea
3
6128
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 the production server the global.asax code behind is compiled into the project.dll (i guess). This renders the physical paths unusable (naturally). Coming from
22
3802
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 manipulate them. It starts > and ends with <script></script> tags. > > Yours looks like a compiled version of it.
12
3829
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 (the oleDBConnection on global.asa.vb) at the other aspx pages ?
8
4871
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 differences in the way both the objects are handled by IIS. Are both objects stored in different memory spaces? I can access both the objects in my web page. I will be grateful if some one can help me understand the difference.
1
3313
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 probably more common than HttpHandlers, but could still stand to be advertised a bit more. HttpModules are incredibly easy to explain, so this will hopefully be a short-ish post. Simply put, HttpModules are portable versions of the global.asax....
8
3549
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 "Identity Impersonate=true" in the web.config file. Trying to implement a system-wide error trapping mechanism. Nothing fancy, just writing to a log file. The recommended procedure was to
1
1880
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 file, how can the global.asax detect the right web.config file ?
5
1397
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 I am missing here? I've copied (shamelessly) the script from here: http://easerve.com/developer/tutorials/asp-net-tutorials-global-error-handling.aspx
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9481
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10155
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.