开发者

Problems enabling SessionState in ASP.NET

开发者 https://www.devze.com 2023-01-07 07:39 出处:网络
My attempts at enabling SessionState are failing :-( I\'ve added the following page directive to the page:

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 f开发者_如何学JAVAollowing error:

The entry 'session' has already been added.

Can anyone assist?

Thanks!

...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消