Alachisoft NCache 4.1 - Online Documentation

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.
    <add assembly = "Alachisoft.NCache.SessionStoreProvider, Version=x.x.x.x, Culture=neutral, PublicKeyToken=CFF5926ED6A53769"/>
    <sessionState cookieless = "false" regenerateExpiredSessionId = "true" mode = "Custom" customProvider = "NCacheSessionProvider" timeout = "10">
    <add name = "NCacheSessionProvider" type = "Alachisoft.NCache.Web.SessionState.NSessionStoreProvider"
    sessionAppId = "1234" cacheName = "myQSReplicatedCache" writeExceptionsToEventLog = "false"
    enableLogs = "false" enableDetailLogs = "false" exceptionsEnabled = "false"/>
    For detailed description of different key-value pairs specified above, please see Using Session State Store Provider.
  • 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.
    <section name = "ncache" type = "Alachisoft.NCache.Web.SessionStateManagement.NCacheSection,
    Alachisoft.NCache.SessionStateManagement, Version=x.x.x.x, Culture=neutral, PublicKeyToken=CFF5926ED6A53769"/>
    <ncache >
    <sessionLocation >
    <primaryCache id = "myQSReplicatedCache" sid-prefix = "abcd"/>
    <secondaryCache id = "myQSReplicatedCache2" sid-prefix = "pqrs"/>
    <secondaryCache id = "myQSReplicatedCache3" sid-prefix = "wxyz"/>
    For detailed description of different key-value pairs specified above, please see Using Location Affinity for Sessions.
  • 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
Copyright © 2005-2012 Alachisoft. All rights reserved.