【问题标题】:configuring ncache asp.net sessionstate provider配置 ncache asp.net sessionstate 提供程序
【发布时间】:2013-11-29 11:41:29
【问题描述】:

我正在尝试将我的 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 管理控制台统计信息中。

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

【问题讨论】:

    标签: asp.net asp.net-mvc session session-state ncache


    【解决方案1】:

    我意识到我需要将 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 缓存中。

    【讨论】:

    猜你喜欢
    • 2011-12-25
    • 1970-01-01
    • 2015-11-28
    • 1970-01-01
    • 1970-01-01
    • 2020-08-12
    • 1970-01-01
    • 1970-01-01
    • 2013-03-27
    相关资源
    最近更新 更多