简体   繁体   English

实现自定义SessionIDManager

[英]Implementing a custom SessionIDManager

I'm trying to implement a custom SessionIDManager very similar this example . 我正在尝试实现一个非常类似于此示例的自定义SessionIDManager。

I'm putting this in the web.config similar to how they showed in the example: 我把它放在web.config中,类似于他们在示例中显示的内容:

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

However when attempting to load the website I am getting the configuration error: 但是,当尝试加载网站时,我收到配置错误:

ProjectName.WebUI.Models.CustomSessionIDManager does not implement IHttpModule. ProjectName.WebUI.Models.CustomSessionIDManager未实现IHttpModule。

If I remove that part of the web.config, the website loads, but the overridden part of the custom SessionIDManager does not get run. 如果我删除web.config的那一部分,网站会加载,但自定义SessionIDManager的重写部分不会运行。

How do I properly tell the web.config to use my custom SessionIDManager? 如何正确告诉web.config使用我的自定义SessionIDManager?

In fact I think there's a bug in the documentation. 事实上,我认为文档中存在一个错误。 You don't need to add it to the <httpModules> section but to the <sessionState> section as illustrated here : 您不需要将它添加到<httpModules>部分,而是添加到<sessionState>部分,如下所示

<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"
/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM