我希望能够使用dedicated or co-located caching在我的 Azure Web 角色中。
问题是我正在迁移的应用程序广泛使用 HttpSessionState
。我不想更改所有这些代码,因为:
这耗时(尤其是测试)
我无法强制开发人员使用
HttpSessionState
我希望尽可能避免供应商锁定
是否没有用于专用和同地缓存的 session 提供程序,以便我可以按原样保留现有代码?
最佳答案
我解决了这个问题。要在专用或并置 Azure 缓存中使用 ASP.NET session 状态,需要在 web.config 中设置以下 session 提供程序:
<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>
关于azure - 在 Web 角色中使用 HttpSessionState,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17725980/