Last post Aug 22, 2011 06:50 AM by sirdneo
Aug 20, 2011 07:55 AM|Islam Eldemery|LINK
Is there anyway to store application state in database?
Aug 20, 2011 10:40 AM|fayaz_3e|LINK
Yes. Configure it to sql server. The following urls might help you...
Aug 21, 2011 06:24 AM|Islam Eldemery|LINK
Fayaz, Thanks for your reply.
I'm looking for a way to store application state in database (not session state), and I think output cache is ideal for caching sql data in asp.net pages.
Actually I'm making a long process operation (6 to 7 minutes) in the application_start to build an object and then store that object in the application state, now every time I change the code (normally in development time) and start debugging the application
gets lost and restarted because its stored in a volatile storage which is the server memory.
What I'm looking for is a way to stop restarting the application or saving the application state in a non-volatile storage such as database.
Aug 21, 2011 10:10 PM|fayaz_3e|LINK
You are getting issues while coding only. So when you deploy it doesn't really worrying you. So better leave that way. Cause the Application state stored in memory is far faster than in DB. The way i mean DB is not like the way we work with session management
in sql server. Session management asp.net allows yo to store it in sql server. But Application state as per msdn article it stores in memory only(no DB). There is no built in support for Application state in DB. Again this is not something what .net needs
to provide you. You can write you own logic to save and retrieve from DB. Serialize the object what you are storing in application state and insert it in DB. You can retrieve the same in Application_Start.
BTW before going to all these things, I read the following article which I mentioned above also. In this article they were speaking about StaticObjects of Application state. As we know static types scope is AppDomain. Good only. So first try StaticObjects.
If this resolves your issue, no worries. If it doesn't, think again whether you want to go for sql server or not. Because the issue is occurring to you while developing/debugging only.
Aug 22, 2011 06:50 AM|sirdneo|LINK
Why you are storing that information in Application State and then trying to store Application State into database?
I recommend you to convert that information into XML and then save it to file/database.
Now when Application_start will fire 2nd time, you can directly load data from file/database instead of calculating again.
Here is the tutorial which will giude you how to convert memory objects into XML:-