NCache 4.3 - Online Documentation

Session State Store Provider

 
NCache Session State Provider is a custom SessionStateStoreProviderBase implementation for an ASP.NET application. This implementation reads and writes ASP.NET session data from and to the cache. This allows you to transparently save and retrieve ASP.NET session-state objects within a webfarm. SSP is a better approach than HttpModule for implementing the ASP.NET sessions. It is flexible and more reliable than HttpModule.
Note: This feature is available only for .NET Framework version 2.0 and later.
 
 
Configuration Steps
 
Please follow these steps for enabling NCache Session Store Provider to transparently save and retrieve ASP.NET session state.
 
1. Edit your application's web.config file and modify the <sessionState> section as given below. Place the following code under <System.Web> tag.
 
<assemblies>
<add assembly = "Alachisoft.NCache.SessionStoreProvider,
Version=x.x.x.x, Culture=neutral,
PublicKeyToken=CFF5926ED6A53769"/>
</assemblies>
<sessionState cookieless = "false"
regenerateExpiredSessionId = "true"
mode = "Custom"
customProvider = "NCacheSessionProvider"
timeout = "10">
<providers>
<add name = "NCacheSessionProvider"
type = "Alachisoft.NCache.Web.SessionState.NSessionStoreProvider"
sessionAppId = "1234"
cacheName = "myCache"
enableSessionLocking = "false"
sessionLockingRetry = "-1"
writeExceptionsToEventLog = "false"
enableLogs = "false"
enableDetailLogs = "false"
exceptionsEnabled = "false"
operationRetry = "0"
operationRetryInterval = "0"/>
</providers>
</sessionState>
 
Note:
Replace version “x.x.x.x” with the actual NCache version that you have.
 
 
Following is the description of different key-value pairs specified above:
 
  • sessionAppId : Optional string attribute. Specifies an identifier to make sure that session id remains unique in case multiple applications are using same cache. Application id should be same for an application in a web farm. If no app id is specified nothing will be concatenated with session id.
  • cacheName: Required string attribute. Specifies the name of the cache to be used for caching session. If no cache name is specified, a configuration exception will be thrown.
  • enableSessionLocking: Optional Boolean attribute. If this flag is set, NCache Session Store Provider exclusively locks the session-store item for which multiple concurrent requests are made. The default is false. Read Session Locking in NCache Session Store Provider
  • sessionLockingRetry: Optional Integer attribute. If enableSessionLocking is true and this integer is not less than 0, NCache Session Store Provider will return empty session after sessionLockingRetry number of retries to acquire a lock. The default is -1. Read Session Locking in NCache Session Store Provider
  • writeExceptionsToEventLog : Optional Boolean attribute. If this flag is set, all the exceptions from cache API are written to event logs. The default is false.
  • enableLogs: Optional Boolean attribute. When this flag is set, store provider logs all error information. The log files are created in "$ncache-install/log-files/SessionStoreProvider/". The default is false.
  • enableDetailLogs: Optional Boolean attribute. When this flag is set, store provider logs all debugging information. The log files are created in "$ncache-install/log-files/SessionStoreProvider/". The default is false.
  • exceptionsEnabled: Optional Boolean attribute. Specifies whether exceptions from cache API are propagated to the page output. Setting this flag is especially helpful during development phase of application since exceptions provide more information about the specific causes of failure. The default is false.
  • operationRetry: In a scenario where connection is lost with a server while an operation is executing, there is a possibility that operation will be lost during that time interval. operationRetry specifies the number of times the server will try to resume the operation . Its default value will be zero.
  • operationRetryInterval: It specifies the time interval between each operation retry, in case connection is lost with the server. Its default value will be zero.
 
 
2. Add <machinekey> entry under <system.web> section in web.config. It is required to generate ASP.NET session IDs in the same manner on all nodes. You can use the genmackeys utility available with NCache installation to generate the keys.
 
<machineKey
validationKey = "A01D6E0D1A5D2A22E0854CA612FE5C5EC4AECF24"
decryptionKey = "ACD8EBF87C4C8937"
validation = "SHA1"/>
 
 
See Also
 
© Copyright  2014 Alachisoft. All rights reserved.