Search code examples
asp.netoutputcachepage-state

what is a page state? and what and where is outputcache directive trying to save?


I observed that there is savepagestatetopersistencemedium method, and we can override and implement them to save them to cache or session or whatever, so what is a page state? And I have no idea what the outputcache directive to trying to save, the viewstate or the html rendering? what is a viewstate exactly?


Solution

  • You have two topics listed: one, which is the state of a page, and output caching, which is the caching of the page response. For output caching, the page lifecycle does not fire for subsequent requests of the cached page (until the cache is removed) as a way to save on performance. Persistence is the persistence of the data on the page between requests. ViewState is a mechanism to not lose a form's data across postbacks (since the web is stateless). You can use the savepagestatetopersistencemedium method to customize how the saving and loading can work, like by compressing viewstate.