509.949.2162 jeremy@bondbyte.com

I tried using Session state today in a web part I was developing, it failed, the session was always null. I followed the best practices, verified it was enabled in web.config, it wasn’t, so I turned it on. EnableSessionState=”true”.

 

I tried my webpart again, same thing, null. So I ran Enable-SPSessionStateService. It returned the following error.

 

Enable-SPSessionStateService : An update conflict has occurred, and you mustre-try this action. The object SPWebService was updated by YVCC\mossapp, inthe OWSTIMER (1304) process, on machine SP2013.  View the tracing log for moreinformation about the conflict.At line:1 char:1+ Enable-SPSessionStateService -DefaultProvision+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : InvalidData: (Microsoft.Offic…teServiceCmdlet:   EnableSessionStateServiceCmdlet) [Enable-SPSessionStateService], SPUpdated  ConcurrencyException    + FullyQualifiedErrorId : Microsoft.Office.Server.Administration.EnableSes   sionStateServiceCmdlet I ran another command, Get-SPSessionSateSerivce and it returned Enabled Timeout  Database Server      Database Catalog     Database Id ——- ——-  —————      —————-     ———– False   01:00:00

Well that confirms my suspicions, session state isn’t configured correctly. So I started doing some digging and appears there can be a problem with caching in the server side. To fix this problem go to Services and stop the SharePoint Timer Service. Go to \ProgramData\Microsoft\SharePoint\Config

and delete all the files in the GUID named folders except the .INI file and restart the service. http://support.microsoft.com/kb/939308?wa=wsignin1.0  

*By the way, you can’t use SessionState with Sanbox Soltuions