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

时间:2013-07-18 22:38:00

标签: session-state appfabric appfabric-cache

是否可以为.net 2.0应用程序设置会话状态缓存?我能够使用.net 4.0应用程序,但没有运气2.0。

如果我将提供程序基于Microsoft.Web.DistributedCache,它会失败,因为它太新了,如果我尝试从Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider执行它,它会抱怨web.config的格式指向类型= “Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider”。

这甚至可能吗?谁能指出我正确的方向?

由于

1 个答案:

答案 0 :(得分:1)

AppFabric会话状态提供程序1.1(Microsoft.Web.DistributedCache.dll)需要.net 4并添加许多新功能。您可以看到如何配置它here,但无法将其用作.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>
相关问题