1

是否可以为 .net 2.0 应用程序设置会话状态缓存?我能够让它与 .net 4.0 应用程序一起工作,但对 2.0 没有任何运气。

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

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

谢谢

4

1 回答 1

1

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>
于 2013-07-22T07:19:14.857 回答