Steve Danner
Steve Danner

Reputation: 22158

Enabling Session State in SharePoint 2010?

I have a web service built for SharePoint 2007 that I am trying to port to SharePoint 2010. This web service is dependent on session state to function properly, but so far, I have been enable to get session state to work at all in SharePoint 2010. This web service runs as its own web application under t he /_vti_bin virtual directory. I have tried all of the following with no luck:

Additional Environment info:

Had anyone had any luck getting a web application or web service to use session state in SharePoint 2010 yet?

Thanks!

Steve

Upvotes: 9

Views: 22985

Answers (5)

carol
carol

Reputation: 1

Do like below:

 <modules runAllManagedModulesForAllrequests>
   <add name="Session" type="System.Web.SessionState.SessionStateModule" />
 </modules>

modules is an xml tag. I don't know why, this post is not taking xml tags..

Thanks

Carol

Upvotes: 0

Joshua
Joshua

Reputation: 905

You've already answered this yourself somewhere else on the interweb. :)

<httpModules> 
  <add name="Session" type="System.Web.SessionState.SessionStateModule" /> 
</httpModules>

THEN, you must go into your web application and add the same session state module to the IIS7 managed pipeline.

  1. Open IIS 7 manager, and find your web application.

  2. Double click "Modules" in the IIS section.

  3. Click "Add Managed Module..." on the right hand pane.

  4. In the Add Managed Module dialog, enter "SessionState" or something like that for the name, and choose the following item from the dropdown:

    System.Web.SessionState.SessionStateModule, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

After that, session state should be enabled for your web app/web service!

Upvotes: 11

Dave Milner
Dave Milner

Reputation: 61

You may need to turn on the Session State Service. Use the PowerShell cmdlet Enable-SPSessionStateService. This will create a Session State database and start the service in SharePoint 2010.

Reference information: http://technet.microsoft.com/en-us/library/ee890113.aspx

Upvotes: 6

anonymous
anonymous

Reputation: 3544

Joshua's solution helped point me in the right direction but I had to make some variations for my scenario - an ASP.NET 3.5 Web Site deployed to the _layouts folder.

Here are the steps that worked for me:

  1. changed the <pages> tag in the web.config for the Web Site to <pages enableSessionState="true" />

  2. Added the System.Web.SessionState.SessionStateModule module at the Sharepoint website level (not the entire IIS level - that'll break the Central Administration, I tried :( ) as per @Joshua's solution. If you're deploying a Web Application instead of a Web Site, you'll want to add it at your Web Application level.

Adding the SessionState HTTPModule below to the web.config didn't seem to have an effect for me, probably because I was riding on Sharepoint's web.config as my project was a Web Site and not a Web Application. Not too clear on this issue.

<httpModules> 
    <add name = "Session" type = "System.Web.SessionState.SessionStateModule" /> 
</httpModules>

Upvotes: 1

Related Questions