Question

Is it possible to setup session state caching for a .net 2.0 application? I was able to get it work with a .net 4.0 app but not having any luck with 2.0.

If i base the provider on the Microsoft.Web.DistributedCache it fails because its too new, if i try to do it off the Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider it complains about the format of the web.config pointing at the type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider".

Is this even possible? can anyone point me in the right direction?

Thanks

Était-ce utile?

La solution

AppFabric Session State Provider 1.1 (Microsoft.Web.DistributedCache.dll) requires .net 4 and adds many new features. You can see how to configure it here but there is no way to use it as a state provider for a .net 2.0 web site.

Hopefully, AppFabric Session State Provider 1.0 (Microsoft.ApplicationServer.Caching.Client.dll) is compatible with AppFabric 1.1. You just have to be carefull on the web.config because the configuration section is not the same.

Here is a very basic web.config :

  <?xml version="1.0" encoding="utf-8" ?>
  <configuration>

  <!--configSections must be the FIRST element -->
  <configSections>
     <!-- required to read the <dataCacheClient> element -->
     <section name="dataCacheClient"
         type="Microsoft.ApplicationServer.Caching.DataCacheClientSection,
            Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, 
            Culture=neutral, PublicKeyToken=31bf3856ad364e35"
         allowLocation="true"
         allowDefinition="Everywhere"/>
  </configSections>

  <!-- cache client -->
  <dataCacheClient>    
    <!-- cache host(s) -->
    <hosts>
      <host
         name="YOURSERVERHERE"
         cachePort="22233"/>
    </hosts>
  </dataCacheClient>

  <system.web>
    <sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider">
      <providers>
        <!-- specify the named cache for session data -->
        <add 
          name="AppFabricCacheSessionStoreProvider" 
          type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider" 
          cacheName="NamedCache1"
          sharedId="SharedApp"/>
      </providers>
    </sessionState>
  </system.web>
</configuration>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top