want_to_be_calm
want_to_be_calm

Reputation: 1627

static variable persistence in IIS

I have used static variable which I hope it will persist in IIS. But for sometimes, it is cleared. Is that possible that IIS will clear the static variable?

public partial class Main : CustomPage
 {
    public static bool cachedCurrentYearDataInFile = false;

Upvotes: 0

Views: 1011

Answers (1)

Cleptus
Cleptus

Reputation: 3541

static variables live though the application cycle. If the application ends (chech application pool settings like idle and recycle) a new instance is generated and you would lose all static information of the now non-existant one. If you want persistence you should consider, actual persistence like file/database.

Upvotes: 4

Related Questions