我正在尝试实现一个非常相似的自定义 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/