2013-07-18 39 views
1

是否可以爲.net 2.0應用程序設置會話狀態緩存?我能夠使用.net 4.0應用程序工作,但沒有任何運氣與2.0。AppFabric 1.1用於.net 2.0應用程序上的會話狀態緩存

如果我基於Microsoft.Web.DistributedCache提供程序它失敗,因爲它太新,如果我嘗試從Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider它它抱怨web.config指向的格式type =「Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider」。

這甚至可能嗎?任何人都可以將我指向正確的方向嗎?

感謝

回答

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> 
相關問題