• Webinars
  • Docs
  • Download
  • Blogs
  • Contact Us
Show / Hide Table of Contents
  • Getting Started with NCache
  • Setting up NCache Environment
  • Create Cache
  • NCache API Caching
  • ASP.NET Session State
  • ASP.NET Core Session
  • ASP.NET View State
  • ASP.NET Output Cache
  • NHibernate
  • Entity Framework Integration

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:

Refer Alachisoft.NCache.SessionStoreProvider in your project from %NCHOME%/bin/assembly/4.0.

Modify Assemblies Tag

In order to configure ASP.NET Session State, you need to modify the following tags in Web.config of your project, under the <system.web>...<compilation> tags:

Enterprise Edition:

<assemblies>
  <add assembly ="Alachisoft.NCache.SessionStoreProvider, Version=x.x.x.x,
Culture=neutral, PublicKeyToken=CFF5926ED6A53769"/>
</assemblies>

Community 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.9.0.0.

Modify sessionState Tag

In order to configure ASP.NET Session State, you need to configure the sessionState tag under <system.web> in Web.config of your project:

<system.web>
  ...
  <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>
...
</system.web>

Modify MachineKey Tag for Web Farms

In case of web farms, 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"/>
Back to top Copyright © 2017 Alachisoft