ASP.NET Session State
Storing ASP.NET sessions in NCache requires no programming. NCache Session State
Provider is a custom SessionStateStoreProviderBase
implementation for an
ASP.NET application. In order to configure ASP.NET Session State, you need to modify the following tags in Web.config of your project:
Important
Refer Alachisoft.NCache.SessionStoreProvider in your project from
[InstallDir]/bin/assembly/4.0
.
Modify Assemblies Tag
Enterprise Edition:
<assemblies>
<add assembly ="Alachisoft.NCache.SessionStoreProvider, Version=x.x.x.x,
Culture=neutral, PublicKeyToken=CFF5926ED6A53769"/>
</assemblies>
Professional and Open Source Edition:
<assemblies>
<add assembly ="Alachisoft.NCache.SessionStoreProvider, Version=x.x.x.x, Culture=neutral, PublicKeyToken=1448e8d1123e9096"/>
</assemblies>
Note
Replace Version=x.x.x.x with the actual NCache version that you have installed. For example, Version=4.8.0.0.
Modify Tag
<configuration>
...
<sessionState cookieless="false"
regenerateExpiredSessionId="true"
mode="Custom"
customProvider="NCacheSessionProvider"
timeout="20">
<providers>
<add name="NCacheSessionProvider"
type="Alachisoft.NCache.Web.SessionState.NSessionStoreProvider"
cacheName="mySessionCache"
sessionAppId="NCacheApp"
exceptionsEnabled="true"
writeExceptionsToEventLog="false"
enableLogs="false"
enableSessionLocking="true"
sessionLockingRetry="-1"
emptySessionWhenLocked="false" />
</providers>
</sessionState>
...
</configuration>
Modify MachineKey Tag
Add <machineKey>
entry under <system.web>
section. It is required to generate ASP.NET session IDs in the same manner on all nodes.
Learn about how to generate a machine-key for a web farm: Generate a Machine Key for a Web Farm (IIS 7)
<machineKey validationKey ="A01D6E0D1A5D2A22E0854CA612FE5C5EC4AECF24"
decryptionKey ="ACD8EBF87C4C8937" validation ="SHA1"/>