Welcome Guest! To enable all features please Login or Register.



System.Web.HttpException : Session state can only be used when enableSessionState is set to true,
#1 Posted : Friday, December 7, 2018 9:01:28 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 7/11/2014(UTC)
Posts: 58
Location: United States of America

Was thanked: 6 time(s) in 6 post(s)
I realize this might be a long-shot trying to get an answer in this forum. But I have a little bit of hope that another NCrunch user ran into and solved this problem and can suggest a solution.

I posted this question in StackoverFlow:

I've reviewed all related posts on this topic in StackoverFlow and other forums.

I'm trying to test code modules which use session state using NUnit and NCrunch. So I'm not in the normal ASPX context.

In an NUnit test method:

I create a page object: Page_Obj = New Page()

Then I call a method to be tested and try to pass Page_Obj.Session.


Then I get the error listed in the Subject line.

I've updated app.config with all the suggestions I could find:

<httpRuntime targetFramework="4.5"/>
<pages enableSessionState="true"></pages>
<sessionState mode="InProc"></sessionState>
<modules runAllManagedModulesForAllRequests="true">
<remove name="session"></remove>
<add name="Session" type="System.Web.SessionState.SessionStateModule" preCondition=""/>

Also, I made sure the ASP.NET Session service was running on my machine.

What else can I do to get a valid Session object in the NCrunch environment?

Thanks, Ed
#2 Posted : Friday, December 7, 2018 11:33:02 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 5,671

Thanks: 737 times
Was thanked: 944 time(s) in 899 post(s)
Hi Ed,

My knowledge of ASP.NET in this area is quite dated, so I'm not sure how much help I can be directly on this. I'm not aware of anything the test runner specifically needs to do in order for the Session to be active ... I was under the impression that these sorts of things were usually arranged by the framework itself and/or setup code in the test.

Do you receive a different result in this test when running it with a non-NCrunch test runner? (i.e. VSTest, or the NUnit console tool).

Something worth trying if you haven't already is to try compatibility mode to see if this is being caused by an NCrunch settings related issue.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.023 seconds.