views:

203

answers:

3

Any good way to preserve ASP.NET Application state across restarts?

I want to be able to set some values restart the app and have them still be there. I want to primarily do this for small "throw-away" test web apps that don't even need a database.

Is there some way to do it with static members and serialization? web cache?

UPDATE:
Application should be able to update these values.
Values could be custom objects like:

public class Person    
{  
  public string FirstName { get; set; }  
  public string LastName { get; set; }      
}
+1  A: 

You need some sort of persistent data storage, whether that's a database, xml files or something else.

You might be interested in the SimpleRepository with SqlLite from SubSonic which gets pretty close to what you describe.

John Sheehan
I'm trying to go a tad bit lighter. But I did SimpleRepo with SQLite yesterday. I wonder if serialize to XML is the only other way besides db4o and subsonic.
tyndall
+1  A: 

Why not just use the ASP.NET State Service:

http://msdn.microsoft.com/en-us/library/ms972429.aspx

Am I missing something?

Nissan Fan
Session state is lost when the process restarts. It is not persistent.
Nader Shirazie
Nader, session state will not be lost when you do an app restart if you use the ASP.NET State Service. That runs outside the process of your application.
Nissan Fan
But it would be a user by user thing right?
tyndall
A: 

I believe that you can store the ASP .NET session in a SQL Server Server database. I'd imagine that would persist it across application restarts, or even shutdowns/reboots.

SkippyFire