Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Global.asax On_Start Variables resetting

Reply
Thread Tools

Global.asax On_Start Variables resetting

 
 
Israel Ordonez Jr
Guest
Posts: n/a
 
      11-18-2003
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!


 
Reply With Quote
 
 
 
 
Alvin Bruney
Guest
Posts: n/a
 
      11-18-2003
Any number of things can cause the application to reset. In your case, I
suspect it may be the idle time causing the recycle event. After an idle
period the app recycles. This is controlled in the machine config file and
IIS management. One easy suggestion is to place code in the application_end
event to store the data to disk , in the registry, in a cookie or somewhere
persistent. In the application_start event, you would first set the default
value, then check the store to see if it contains valid data, setting the
value if it is other than the default value.

One other suggestion, application object is provided for backward
compatibility so you should try to avoid it's use. You may use a static
variable or better yet wrap the variable in a class which knows how to store
and retrieve values during application recycle events. The class approach is
better because sooner or later, you may want other long lasting objects as
well.

regards
--


-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Israel Ordonez Jr" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
Application variables not resetting tshad ASP .Net 2 07-19-2006 06:49 PM
gateway not resetting Dwight Wireless Networking 2 04-15-2005 07:52 PM
Resetting =?Utf-8?B?U25vb2s=?= Wireless Networking 4 02-03-2005 08:18 AM
Global.asax On_Start Variables resetting Israel Ordonez Jr ASP .Net 4 11-18-2003 08:37 AM



Advertisments