1

我正在尝试将我的 Visual Studio 2013 asp.net mvc 应用程序配置为将 ncache 提供程序用于会话状态。

到目前为止,我已经添加了对 Alachisoft.NCache.SessionStoreProvider 和 Alachisoft.NCache.Web 的项目引用

我也按照此处找到的步骤进行操作,包括关于 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 管理控制台统计信息中。

谁能描述他们是如何设置的或看到我遗漏的任何东西?提前致谢

4

1 回答 1

0

我意识到我需要将mode="Custom"customProvider="XXXX"属性添加到 web 配置中的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 缓存中。

于 2013-11-29T03:41:29.447 回答