locked
Store Application State in Database RRS feed

  • Question

  • User-1242913921 posted

    Is there anyway to store application state in database?

    Saturday, August 20, 2011 7:55 AM

Answers

  • User-573138384 posted

    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.

    ApplicationState

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

    StaticObjects

    http://msdn.microsoft.com/en-us/library/system.web.httpapplicationstate.staticobjects.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 21, 2011 10:10 PM

All replies

  • User-1242913921 posted

    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.

    Sunday, August 21, 2011 6:24 AM
  • User-573138384 posted

    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.

    ApplicationState

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

    StaticObjects

    http://msdn.microsoft.com/en-us/library/system.web.httpapplicationstate.staticobjects.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, August 21, 2011 10:10 PM
  • User-481631678 posted

    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:-

    http://zeeshanumardotnet.blogspot.com/2011/05/xml-serilization-tutorial.html

    Monday, August 22, 2011 6:50 AM