Under what conditions would Application variables go away?

M

Michael Bray

I have an application that has a webservice, and the web service is
utilizing Application variables to store login tokens for clients.
However, the application variable seems to be disappearing on occasion, and
I think it is because the application is somehow timing out and restarting.

Can anyone identify in what circumstances this might occur? Thanks!

-mdb
 
G

Guest

IIS applications recycle due to a number of issues - memory pressure, IIS
Settings that make it recycle after a certain period of time, and unhandled
exceptions, among other reasons.

If you want to be able to preserve your Application variables across app
restarts, you should restore them in the Application_Start event handler in
Global.asax.
Peter
 
M

Michael Bray

=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
If you want to be able to preserve your Application variables across
app restarts, you should restore them in the Application_Start event
handler in Global.asax.

But where would I store them that they would persist across Application
Restarts? I would have thought the Application[...] variable, but
wouldn't those variables go away when the app does restart??

-mdb
 
J

John Saunders

Michael Bray said:
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
If you want to be able to preserve your Application variables across
app restarts, you should restore them in the Application_Start event
handler in Global.asax.

But where would I store them that they would persist across Application
Restarts? I would have thought the Application[...] variable, but
wouldn't those variables go away when the app does restart??


If these are tokens related to clients, then won't the client connections
and any associated data be destroyed by an app restart?

John
 
M

Michael Bray

Michael Bray said:
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
If you want to be able to preserve your Application variables across
app restarts, you should restore them in the Application_Start event
handler in Global.asax.

But where would I store them that they would persist across
Application Restarts? I would have thought the Application[...]
variable, but wouldn't those variables go away when the app does
restart??


If these are tokens related to clients, then won't the client
connections and any associated data be destroyed by an app restart?

John

Yes that is the problem that we are experiencing... In other words, the
login token is being stored in a Hashtable that is stored in the
Application[...] variable. The clients are crashing when, it appears, the
Application_OnStart gets called and the hashtable is created anew, and
stored in the Application[...]. That's what the original question was
asking, to verify that this is what was (ie that it could) happen this way.
It seems that my suspicion was correct.

I guess the question is, how can I prevent the application from recycling,
or is there a better place to store user login token information? The
application is the highest-level object in terms of lifecycle that I know
of. The only other option would be to store in external system such as
SQL.

-mdb
 
J

John Saunders

Michael Bray said:
Michael Bray said:
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
If you want to be able to preserve your Application variables across
app restarts, you should restore them in the Application_Start event
handler in Global.asax.

But where would I store them that they would persist across
Application Restarts? I would have thought the Application[...]
variable, but wouldn't those variables go away when the app does
restart??


If these are tokens related to clients, then won't the client
connections and any associated data be destroyed by an app restart?

John

Yes that is the problem that we are experiencing... In other words, the
login token is being stored in a Hashtable that is stored in the
Application[...] variable. The clients are crashing when, it appears, the
Application_OnStart gets called and the hashtable is created anew, and
stored in the Application[...]. That's what the original question was
asking, to verify that this is what was (ie that it could) happen this
way.
It seems that my suspicion was correct.

I guess the question is, how can I prevent the application from recycling,
or is there a better place to store user login token information? The
application is the highest-level object in terms of lifecycle that I know
of. The only other option would be to store in external system such as
SQL.

You can't entirely prevent an application from restarting, and in fact, you
couldn't depend on that in any case. What if your server system reboots?

Any solution to your problem must solve the "reboot" question. Storing these
tokens in a database would be one way to solve that. Another way would be
for your code to be more robust in the face of a missing token. If the token
is missing, the clients should log in again.

John
 
M

Michael Bray

You can't entirely prevent an application from restarting, and in
fact, you couldn't depend on that in any case. What if your server
system reboots?

Any solution to your problem must solve the "reboot" question. Storing
these tokens in a database would be one way to solve that. Another way
would be for your code to be more robust in the face of a missing
token. If the token is missing, the clients should log in again.

Yes I would agree on the reboot - but I don't think it is unreasonable to
expect clients to have to restart when the server restarts - it would
certainly be nice if they didn't have to. I guess I was just looking for
confirmation that Application variables would go away if the application
restarts (and in particular why an application would restart) without the
server physically rebooting.

-mdb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top