From: Chris on
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


From: Nick Gilbert on

On 03/06/2010 16:53, Chris wrote:
> 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.