lifetime of Session and Application ???

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hello.

Lifetime of Session-data is specified in web.config.

But what about Application-data?

I have a little testWebApp in which Session-timeout is set to 1 minute

Application["AppData"] = 1;
Session["SessionData"] = 2;

lblAppData.Text = Application["AppData"] != null ?
Application["AppData"]: "Expired"
lblSessionData.Text = Session["SessionData"] != null ?
Session["SessionData"]: "Expired"

refreshing the page after more than 1 minute displays "Expired" for
Session but keeps on showing the Application-data.

So, what determines the lifetime of Application-data?

thx
Chris
 
Hello.

Lifetime of Session-data is specified in web.config.

But what about Application-data?

I have a little testWebApp in which Session-timeout is set to 1 minute

Application["AppData"] = 1;
Session["SessionData"] = 2;

lblAppData.Text = Application["AppData"] != null ?
Application["AppData"]: "Expired"
lblSessionData.Text = Session["SessionData"] != null ?
Session["SessionData"]: "Expired"

refreshing the page after more than 1 minute displays "Expired" for
Session but keeps on showing the Application-data.

So, what determines the lifetime of Application-data?

Application data only expires if IIS is restarted, or the application
pool it's hosted in is recycled. This can happen if the website is not
accessed for a long time, or if a worker process crashes or is recycled
by IIS due to it using too much RAM. Application variables should not be
treated as a permanent data store and your application should be able to
cope with the Application variables disappearing at any time.

Nick.
 
Back
Top