473,387 Members | 1,700 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,387 software developers and data experts.

Global.asax On_Start Variables resetting

Hi everybody,
I am having a problem with an ASP.NET application i am working on. I new to
ASP.NET so I'm not sure if I'm doing this right.

I am working on a website that has an oil price listed throught several
pages. In the global.asax file i have the following code.

Sub Application_Start(ByVal sender As Object, ByVal e
As EventArgs)
' Fires when the application is started
Application("OilPrice") = "1.14"
Application("PrePay") = "1.14"
End Sub

I reference these variables on other pages. Everything works correctly up to
this point. I have another page were the price can be changed. Once a new
price is changed it reflects on all pages. The problem is after a few hours
or the next day. The price always resets to the "1.14" in the global.asax
file. It was my understanding that the Application_Start event only occurs
once, the first time the application is accessed.

Is my assumption correct? If so what could be causing the variables to be
reset? Thanks!

Nov 18 '05 #1
4 1876
You are partially correct. The Application_Start is fired each time the
applicaiton is started. The application will, eventually, unload from the
server. The application will unload after the very last session closes out
from a timeout. That means, 20 minutes (default time for a session) after
the last person leaves the site the application will unload. The app will
then reload when someone hits it and start the entire process over again.
Applications have to unload eventually to free up resources.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Israel Ordonez Jr" <or******@ordonezconsulting.biz> wrote in message
news:u7**************@TK2MSFTNGP10.phx.gbl...
Hi everybody,
I am having a problem with an ASP.NET application i am working on. I new to ASP.NET so I'm not sure if I'm doing this right.

I am working on a website that has an oil price listed throught several
pages. In the global.asax file i have the following code.

Sub Application_Start(ByVal sender As Object, ByVal e
As EventArgs)
' Fires when the application is started
Application("OilPrice") = "1.14"
Application("PrePay") = "1.14"
End Sub

I reference these variables on other pages. Everything works correctly up to this point. I have another page were the price can be changed. Once a new
price is changed it reflects on all pages. The problem is after a few hours or the next day. The price always resets to the "1.14" in the global.asax
file. It was my understanding that the Application_Start event only occurs
once, the first time the application is accessed.

Is my assumption correct? If so what could be causing the variables to be
reset? Thanks!

Nov 18 '05 #2
Thanks for the information. Could you possibly point me in the right
direction. What I need to do is have an admin page were the price can
be set every now and then, and then have all other pages reference that
variable. I know i can set variables in the appSettings section of the
web.config file, but those are readonly i wouldn't be able to set them
via a form.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3
You could store the values in a database, or an Xml file.
You would read them into you Application variable, and they're still
modifiable.
You could also include code to update your Application variable if the value
is modified

"israel ordonez" <iz****@izzyor.com> wrote in message
news:ea**************@TK2MSFTNGP11.phx.gbl...
Thanks for the information. Could you possibly point me in the right
direction. What I need to do is have an admin page were the price can
be set every now and then, and then have all other pages reference that
variable. I know i can set variables in the appSettings section of the
web.config file, but those are readonly i wouldn't be able to set them
via a form.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #4
SSW
My Suggestion is store it in XML. Load it in to cache and make it Dependent
on XM file. As file is changed the XML value in chance get Discarded and
reload from XML file. This cache value u can refer any where in ur
application.

Hope this helps.

Thanks,

sswalia
MCSD, MCAD, OCA
"George Durzi" <gd****@hotmail.com> wrote in message
news:uN**************@TK2MSFTNGP09.phx.gbl...
You could store the values in a database, or an Xml file.
You would read them into you Application variable, and they're still
modifiable.
You could also include code to update your Application variable if the value is modified

"israel ordonez" <iz****@izzyor.com> wrote in message
news:ea**************@TK2MSFTNGP11.phx.gbl...
Thanks for the information. Could you possibly point me in the right
direction. What I need to do is have an admin page were the price can
be set every now and then, and then have all other pages reference that
variable. I know i can set variables in the appSettings section of the
web.config file, but those are readonly i wouldn't be able to set them
via a form.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Sahil Malik [MVP] | last post by:
So here's a rather simple question. Say in an ASP.NET application, I wish to share common constants as static variables in global.asax (I know there's web.config bla bla .. but lets just say I...
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? ...
5
by: WJ | last post by:
I am attempting to use the Global.Asax to store my user's configuration. Here is the concept: 1. User logs on into the site using Form Authentication. 2. I capture the user Credential, verify it...
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...
2
by: Nathan Sokalski | last post by:
I would like to access variables and functions that I declare in the Global.asax.vb file. However, I am having trouble doing that. What does the declaration have to look like in the Global.asax.vb...
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...
8
by: Rob T | last post by:
When I was using VS2003, I was able to compile my asp.net project locally on my machine and copy it to the production server and it would run just fine. I've now converted to VS2005. The project...
15
by: =?Utf-8?B?UGF0Qg==?= | last post by:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax code file. In 1.1 I could have a code behind file for the global.asax file. This allow for shared variables of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.