我正在尝试配置我的visual studio 2013 asp.net mvc应用程序,以便将ncache提供程序用于会话状态。
到目前为止,我已经添加了一个项目引用Alachisoft.NCache.SessionStoreProvider和Alachisoft.NCache.Web
我也按照here找到的步骤进行了操作,包括关于web.config的第9点,现在我的web.config中有以下system.web部分
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" >
<assemblies>
<add assembly="Alachisoft.NCache.SessionStoreProvider,Version=4.1.0.0,Culture=neutral,PublicKeyToken=CFF5926ED6A53769"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" />
<sessionState cookieless="false" >
<providers>
<add name="NCacheSessionProvider"
type="Alachisoft.NCacheExpress.Web.SessionState.NSessionStoreProvider"
sessionAppId="NCacheTest"
cacheName="MyClusterCache"
writeExceptionsToEventLog="false"
enableLogs="false"/>
</providers>
</sessionState>
</system.web>
然而,当我调试我的应用程序时,它似乎仍然使用默认的inproc会话状态,因为一切正常但我的缓存显示了0个对象的数量。
使用NCache api我可以将项目添加到缓存中,这显示在我的NCache管理控制台统计信息中。
有谁可以描述他们如何设置或看到我遗失的任何内容?提前致谢
答案 0 :(得分:0)
我通过意识到我需要将 mode =“Custom”和 customProvider =“XXXX”属性添加到 sessionState 标记来解决了我的问题在网络配置中。当我添加这些时它起作用了。
我的工作网络配置现在包括
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" >
<assemblies>
<add assembly="Alachisoft.NCache.SessionStoreProvider,Version=4.1.0.0,Culture=neutral,PublicKeyToken=CFF5926ED6A53769"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" />
<sessionState mode="Custom" customProvider="NCacheSessionProvider" cookieless="false" >
<providers>
<add name="NCacheSessionProvider"
type="Alachisoft.NCache.Web.SessionState.NSessionStoreProvider"
sessionAppId="NCacheTest"
cacheName="MyClusterCache"
writeExceptionsToEventLog="false"
enableLogs="false"/>
</providers>
</sessionState>
</system.web>
当我添加到会话状态时,我现在可以看到1个对象已添加到我的NCache缓存中。