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>