I've got an website running on a third-party hosting 开发者_Python百科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?
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.
Sounds like the ASP.NET worker process is being recycled, which happens occasionally. Your app should handle the Application Unload event.
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.
精彩评论