Wednesday, July 13, 2005

Using Session state in a SharePoint Environment

I have been asked so many times by SharePoint developers why can’t they use Session objects in web parts. Normally they get the following error message,

Exception Details: System.Exception: Session state can only be used whenenableSessionState is set to true, either in a configuration file or inthe Page directive

I received following email from a reader that got this problem fix.

Gayan,
How r u ? Well good news is that if you remember we had spoken about the session state in ASP.NET Application and you advised me to use View state, well I have figured out easy approach, we just have enable session state in Web.Config File. If we look at

<system.web>
<identity impersonate="true"/>
<httpmodules>
<clear/>
<add name="OutputCache" type="System.Web.Caching.OutputCacheModule" />

<add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule" />
<!--<addname="Session"

type="System.Web.SessionState.SessionStateModule"/> ---->
</httpmodules>
<globalization fileencoding="utf-8"/>

<compilation debug="false" batch="false"/>

<pages enablesessionstate="false" enableviewstate="true"

enableviewstatemac="true" validaterequest="false"/>

<!-- <addname="Session"

type="System.Web.SessionState.SessionStateModule"/>---/>

we need to uncomment this line out also

"enableSessionState="false" need to be "true"

I don’t know if this is going to help you or not. But it did resolve my issue. I found this article on MSDN here is the link
http://support.microsoft.com/default.aspx?scid=KB;EN-US;828810

Also wanted to say thank you for helping me out.

Best Regards
Attiq Khan

1 Comments:

At 10:21 PM, Anonymous at home careers said...

Your blog I found to be very interesting!
I just came across your blog and wanted to
drop you a note telling you how impressed I was with
the information you have posted here.
I have a at home careers
site.
Come and check it out if you get time :-)
Best regards!

 

Post a Comment

<< Home