用于.net 2.0应用程序上会话状态缓存的AppFabric 1.1



是否可以为.net 2.0应用程序设置会话状态缓存?我能够用.net 4.0应用程序来实现它,但在2.0上运气不佳。

如果我将提供程序建立在Microsoft.Web.DistributedCache上,它会因为太新而失败,如果我尝试在Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider上执行它,它会抱怨指向type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider."的Web.config格式。

这可能吗?有人能给我指正确的方向吗?

感谢

AppFabric会话状态提供程序1.1(Microsoft.Web.DistributedCache.dll)需要.net 4并添加了许多新功能。您可以在这里看到如何配置它,但无法将它用作.net 2.0网站的状态提供程序。

希望AppFabric会话状态提供程序1.0(Microsoft.ApplicationServer.Caching.Client.dll)与AppFabric 1.1兼容。您只需要小心处理web.config,因为配置部分不相同。

以下是一个非常基本的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>