asp.netapplication-state

Application variables get lost after post-back


My ASP.Net application has a Server Control developed by us which needs to store some keys in the Application level (i.e. across users and sessions) for future use. However, I found that the count neither of Page.Application and HttpContext.Current.Application become zero after post-back or page-refresh.

Actually I've been facing such problem in case of Session, but I finally solve the Session persistence problem by changing the SessionState configuration the web.config:

<sessionState cookieless="UseCookies" mode="StateServer" ></sessionState>

However, I don't know if there exists any similar settings for Application State.

Please kindly advise.

Man Thanks!!!

William

-- UPDATE--

I'm using Visual Studio 2008, and the application is being tested on the Visual Studio ASP.Net Testing Server.


Solution

  • Application state should be alive until you reset (iisreset) your web server (application pool) Which kind or web server you are using? Are you testing this on visual studio? did you try to host it to IIS and try? Because Cassini (visual studio development server) has some issues regarding the sessions with me You might try IIS Express - http://learn.iis.net/page.aspx/868/iis-express-overview/ - http://weblogs.asp.net/scottgu/archive/2010/06/28/introducing-iis-express.aspx