I was creating a new visual webpart for MS SharePoint 2010, but since I needed to use sessions I got this error:
Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration>\<system.web>\<httpModules> section in the application configuration.
As error message advice to you, you have to change a config file slightly. Since there is no web.config in visual webpart project, you should change the web.config on your server.
Open the web.config (the one in the folder "intepub") and then set "enableSessionState" property in "pages" tag as below:
<pages enableSessionState="true" ...
then add "remove" and "add" tags to the <system.webServer> (see? Error message advised you to add it to the system.web not to the system.webServer. And this was reason why I was struggling with this for two hours :) )
<system.webServer>
<modules>
<!-- UrlRewriter code here -->
<remove name="Session" />
<add name="Session" type="System.Web.SessionState.SessionStateModule" preCondition="integratedMode" />
</modules>
</system.webServer>
Ok then, thats all... Do not believe alerts everytime ;)
No comments:
Post a Comment