c# - 实现自定义 SessionIDManager

标签 c# asp.net-mvc-2

我正在尝试实现一个非常相似的自定义 SessionIDManager this example .

我把它放在 web.config 中,类似于它们在示例中的显示方式:

<system.web>
  <httpModules>
    <add name="SessionID"
         type="ProjectName.WebUI.Models.CustomSessionIDManager" />
  </httpModules>
  // --snip--
</system.web>

然而,当尝试加载网站时,我遇到了配置错误:

ProjectName.WebUI.Models.CustomSessionIDManager does not implement IHttpModule.

如果我删除 web.config 的那部分,网站会加载,但自定义 SessionIDManager 的覆盖部分不会运行。

我如何正确地告诉 web.config 使用我的自定义 SessionIDManager?

最佳答案

事实上,我认为文档中存在错误。您不需要将其添加到 <httpModules>部分但到 <sessionState>部分为 illustrated here :

<sessionState
    Mode="InProc"
    stateConnectionString="tcp=127.0.0.1:42424"
    stateNetworkTimeout="10"
    sqlConnectionString="data source=127.0.0.1;Integrated Security=SSPI"
    sqlCommandTimeout="30"
    customProvider=""
    cookieless="false"
    regenerateExpiredSessionId="false"
    timeout="20"
    sessionIDManagerType="Your.ID.Manager.Type, CustomAssemblyNameInBinFolder"
/>

关于c# - 实现自定义 SessionIDManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4612310/

相关文章:

jQuery 通用代码

asp.net-mvc-2 - ASP.NET MVC2 IoC : Looking for an example using CaSTLeWindsor container that works with minimum config

c# - 无法将 ref enum 转换为 ref dynamic?

c# - 如何获得实际的请求执行时间

c# - 特定时间运行方法

c# - 在 Visual Studio 解决方案中重新链接 Xaml 和代码隐藏

jquery - JSONP请求成功,但没有返回任何数据

来自 View 模型数据的 JavaScript 参数

C# 从 XML 树中读取元素值

c# - ASP.NET MVC 2 Html.TextAreaFor Html.TextArea 奇怪的绑定(bind)