|
Step 2: Edit web.config or machine.config
After you have configured the cache and have named it "myQSReplicatedCache", you now need to configure your ASP.NET application to use the Custom Session Store Provider that is provided with NCache installation. To do so, you must edit web.config file.
Please follow these steps for enabling NCache Session Store Provider to transparently save and retrieve ASP.NET session state:
-
Edit your application's web.config file and modify the <sessionState> section as given below.
For Enterprise and Professional Edition:-
<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 = "myQSReplicatedCache" writeExceptionsToEventLog = "false"
enableLogs = "false" enableDetailLogs = "false" exceptionsEnabled = "false" operationRetry = "0" operationRetryInterval = "0" />
</providers>
</sessionState>
For Open Source Edition:-
<assemblies>
<add assembly = "Alachisoft.NCache.SessionStoreProvider, Version=x.x.x.x, Culture=neutral, PublicKeyToken=1448e8d1123e9096"/>
</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 = "myQSReplicatedCache" writeExceptionsToEventLog = "false"
enableLogs = "false" enableDetailLogs = "false" exceptionsEnabled = "false" operationRetry = "0" operationRetryInterval = "0" />
</providers>
</sessionState>
|
Replace version “x.x.x.x” with the actual NCache version that you have.
|
-
Add <machinekey> entry under <system.web> section of web.config. It is required, so that ASP.NET session IDs are generated in the same manner on all nodes. You can use genmackeys utility available with NCache installation to generate the keys.
<machineKey validationKey = "A01D6E0D1A5D2A22E0854CA612FE5C5EC4AECF24" decryptionKey = "ACD8EBF87C4C8937"
validation = "SHA1"/>
Enable Location Affinity for SessionStoreProvider
-
Add following section in web.config.
For Enterprise and Professional Edition:-
<configSections>
<section name = "ncache" type = "Alachisoft.NCache.Web.SessionStateManagement.NCacheSection,
Alachisoft.NCache.SessionStateManagement, Version=x.x.x.x, Culture=neutral, PublicKeyToken=CFF5926ED6A53769"/>
</configSections>
<ncache >
<sessionLocation >
<primaryCache id = "myQSReplicatedCache" sid-prefix = "abcd"/>
<secondaryCache id = "myQSReplicatedCache2" sid-prefix = "pqrs"/>
<secondaryCache id = "myQSReplicatedCache3" sid-prefix = "wxyz"/>
</sessionLocation>
</ncache>
For Open Source Edition:-
<configSections>
<section name = "ncache" type = "Alachisoft.NCache.Web.SessionStateManagement.NCacheSection,
Alachisoft.NCache.SessionStateManagement, Version=x.x.x.x, Culture=neutral, PublicKeyToken=1448e8d1123e9096"/>
</configSections>
<ncache >
<sessionLocation >
<primaryCache id = "myQSReplicatedCache" sid-prefix = "abcd"/>
<secondaryCache id = "myQSReplicatedCache2" sid-prefix = "pqrs"/>
<secondaryCache id = "myQSReplicatedCache3" sid-prefix = "wxyz"/>
</sessionLocation>
</ncache>
Please keep the following points in mind:
-
Replace version “x.x.x.x” with the actual NCache version that you have.
-
The sid-prefix is a unique identifier that is appended by custom session-ID manager in the beginning of session-ID. sid-prefix length must be equal to 4.
-
When Location Affinity is enabled, "CacheName" specified in <providers> section of web.config will be ignored.
-
Enable custom session-ID manager using the sessionIDManagerType attribute of the sessionState element in web.config.
<sessionState cookieless = "false" regenerateExpiredSessionId = "true" mode = "Custom"customProvider = "NCacheSessionProvider" timeout = "60" sessionIDManagerType = "Alachisoft.NCache.Web.SessionStateManagement.CustomSessionIdManager, Alachisoft.NCache.SessionStateManagement">
See Also
|
|