1

I'm trying to configure my visual studio 2013 asp.net mvc application to use the ncache provider for session state.

So far I have added a project reference to Alachisoft.NCache.SessionStoreProvider and Alachisoft.NCache.Web

I have also followed the steps found here, including point 9 regarding web.config and now have the following system.web section in my web.config

<system.web>
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.5" >
        <assemblies>
            <add assembly="Alachisoft.NCache.SessionStoreProvider,Version=4.1.0.0,Culture=neutral,PublicKeyToken=CFF5926ED6A53769"/>
        </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5" />
    <sessionState cookieless="false" >
        <providers>
            <add name="NCacheSessionProvider"
                type="Alachisoft.NCacheExpress.Web.SessionState.NSessionStoreProvider"
                sessionAppId="NCacheTest"
                cacheName="MyClusterCache"
                writeExceptionsToEventLog="false"
                enableLogs="false"/>
        </providers>
    </sessionState>
</system.web>

However when I debug my app it still appears to be using the default inproc session state as everything works ok but my cache shows a count of 0 objects.

Using the NCache api I can add items to the cache just fine which shows up in my NCache Management console statistics.

Can anyone describe how they have set this up or see anything I am missing? Thanks in advance

Stewart Evans
  • 1,416
  • 1
  • 12
  • 17

1 Answers1

0

I solved my problem by realising I needed to add mode="Custom" and customProvider="XXXX" attributes to the sessionState tag in the web config. It worked when I added these.

My working Web config now includes

<system.web>
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.5" >
        <assemblies>
            <add assembly="Alachisoft.NCache.SessionStoreProvider,Version=4.1.0.0,Culture=neutral,PublicKeyToken=CFF5926ED6A53769"/>
        </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5" />
    <sessionState mode="Custom" customProvider="NCacheSessionProvider" cookieless="false" >
        <providers>
            <add name="NCacheSessionProvider"
                type="Alachisoft.NCache.Web.SessionState.NSessionStoreProvider"
                sessionAppId="NCacheTest"
                cacheName="MyClusterCache"
                writeExceptionsToEventLog="false"
                enableLogs="false"/>
        </providers>
    </sessionState>
</system.web>

When I add to my session state I can now see 1 object added to my NCache cache.

Stewart Evans
  • 1,416
  • 1
  • 12
  • 17
  • Alachisoft appear to have updated their documentation now which shows the correct configuration needed at http://www.alachisoft.com/resources/docs/ncache/help-4-1/gettingstarted-guide-net.html – Stewart Evans Dec 02 '13 at 02:47