【问题标题】:Using HttpSessionState in web roles在 Web 角色中使用 HttpSessionState
【发布时间】:2013-07-17 13:15:06
【问题描述】:
我希望能够在我的 Azure Web 角色中使用 dedicated or co-located caching。
问题是我正在迁移的应用程序广泛使用HttpSessionState。我不想更改所有这些代码,因为:
这耗时(尤其是测试时)
我无法强制开发人员使用HttpSessionState
我想尽可能避免供应商锁定
是否没有用于专用和同位缓存的会话提供程序,以便我可以保持现有代码不变?
【问题讨论】:
标签:
azure
session-state
azure-storage
azure-web-roles
azure-caching
【解决方案1】:
我解决了这个问题。要在专用或同地 Azure 缓存中使用 ASP.NET 会话状态,需要在 web.config 中设置以下会话提供程序:
<sessionState mode="Custom" customProvider="AFCacheSessionStateProvider">
<providers>
<add name="AFCacheSessionStateProvider"
type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache"
cacheName="default" dataCacheClientName="default"
applicationName="AFCacheSessionState"
/>
</providers>
</sessionState>