By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,019 Members | 1,458 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,019 IT Pros & Developers. It's quick & easy.

Global.asax On_Start Variables resetting

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.