在 ASP.NET 中启用 SessionState 时出现问题
我启用 SessionState 的尝试失败了:-(
我已将以下页面指令添加到页面中:
<%@ Page ... EnableSessionState="True" %>
在我的 web.config 文件中,我添加了以下内容:
<system.web>
...
<sessionState mode="InProc" cookieless="false" />
<pages enableSessionState="true">
...
</pages>
<remove name="session" />
<add name="session" type="System.Web.SessionState.SessionStateModule" />
...
</system.web>
据我认为,这应该有效,我应该能够访问我的代码中的 Session 对象 - 我收到一个 HTTPException,建议我确保以上内容位于我的 web.config 文件中,
条目
<remove name="session" />
因为没有它,我会收到以下错误:
'session 已经添加了。
谢谢
!
'
My attempts at enabling SessionState are failing :-(
I've added the following page directive to the page:
<%@ Page ... EnableSessionState="True" %>
And to my web.config file, I've added the following:
<system.web>
...
<sessionState mode="InProc" cookieless="false" />
<pages enableSessionState="true">
...
</pages>
<remove name="session" />
<add name="session" type="System.Web.SessionState.SessionStateModule" />
...
</system.web>
As far as I believe, this should work and I should be able to access the Session object in my code - I'm getting an HTTPException advising me to make sure the above is in my web.config file.
The following line:
<remove name="session" />
was added because without it I get the following error:
The entry 'session' has already been added.
Can anyone assist?
Thanks!
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您所需要的只是:
从页面和 web.config 中删除其余部分,它应该可以工作。默认情况下启用会话。
All you need is:
Remove the rest from the page and the web.config and it should work. Session is enabled by default.