在 ASP.NET 中启用 SessionState 时出现问题

发布于 2024-09-09 06:19:33 字数 742 浏览 1 评论 0原文

我启用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

無處可尋 2024-09-16 06:19:33

您所需要的只是:

<system.web>
...
    <sessionState mode="InProc" cookieless="false" />
...
</system.web>

从页面和 web.config 中删除其余部分,它应该可以工作。默认情况下启用会话。

All you need is:

<system.web>
...
    <sessionState mode="InProc" cookieless="false" />
...
</system.web>

Remove the rest from the page and the web.config and it should work. Session is enabled by default.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文