views:

21

answers:

3

Hi guys,

I've got an website running on a third-party hosting server. Now I've got a few objects in global asax. But once in like 6 hours or so (didn't really check how long) the object gets reset to default values.

Is this an problem in global asax that it reset's himself or is this the server on which I'm hosting?

+3  A: 

Most likely this is due to the AppPool being recycled.

In IIS you can set how often an AppPool is being recycled based on running time, number of requests or a set time each day. Check with your hosting provider about what settings they have. You can also turn off automatic recycling.

Mikael Svenson
What is the downsite of turning off automatic recycling?
Julian
A: 

Sounds like the ASP.NET worker process is being recycled, which happens occasionally. Your app should handle the Application Unload event.

Jerome
A: 

There are a variety of reasons you ASP.NET application can get recycled by the server, at any moment (see "ASP.NET application recycling").

You should not rely on the state of your Application instance to be maintained: if you need to keep state, store it in a database or to the filesystem.

Lck