Group ASP.NET View State with Session
NCache provides a feature that allows to group View State with a particular
session. Due to this dependency, as the session is expired, the View State
associated with it expires too. The View State and session can reside either on
two different caches or on a single cache. To enable this feature,
expireViewstateWithSession
should be set as true in ncContentOptimization
tag.
<ncContentOptimization>
<settings enableMinification="false"
enableViewstateCaching="true"
groupedViewStateWithSessions="true"
viewstateThreshold="1"
cacheUriMapping="true"
enableTrace="true"
expireViewstateWithSession="true"
sessionCacheName="sessionCache"
sessionAppId="demoApp">
<cacheSettings cacheName="demoClusteredCache">
<expiration type="None" duration="0" >
</cacheSettings>
</settings>
</ncContentOptimization>
Configuration Members
Member | Description |
---|---|
groupedViewStateWithSessions |
Through this property session can be grouped with View State. All the View State for a session is grouped with sessionId. This allows to retrieve all View State grouped with a sessionId from the cache with group information. Set this property to "true" in order to enable View State grouping with sessions. By default, its value is false. |
expireViewstateWithSession |
By setting this property as true, it is made sure that when a session expires, its associated View State expires too. |
sessionAppId |
Specifies an identifier to make sure that session ID remains unique in case multiple applications are using the same cache. Its value should be the same as the sessionAppId in sessionState tag. |
sessionCacheName |
The name of the cache on which the session data is residing. Its value should be the same as the cacheName property in sessionState tag. |
See Also
Configuring and Using NCache Content Optimization
Limit View State Caching
Page Level Grouping for View State
Distributed Cache for ASP.NET Output Caching
ASP.NET SignalR Backplane Overview