0

I am little bit confused... I have the following in my web.config and i am still getting error message. This error only happens when i am logged in since the user info is in the session. In not logged in mode, i just get empty user.

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.

Web.config:

<sessionState mode="SQLServer" allowCustomSqlDatabase="true" sqlConnectionString="data source=MyServer;Initial Catalog=MyDatabase;user id=user;password=password" cookieless="false" timeout="20" />

What am i missing here?

Joel Etherton
  • 37,325
  • 10
  • 89
  • 104
learning...
  • 3,104
  • 10
  • 58
  • 96
  • What event are you attempting to call the session in? Please post the code you're using to access the session that is throwing the exception. – Joel Etherton Mar 21 '13 at 20:27
  • var user = Session[SessionConstants.LoggedInUser] as SiteUSer; – learning... Mar 21 '13 at 20:39
  • You can't call the session so easily from PreInit. See http://stackoverflow.com/questions/1342970/c-sharp-how-to-set-up-and-use-session-state-from-preinit – Nikki9696 Mar 21 '13 at 20:44
  • Are you certain the root exception is being thrown at that line? I've gotten that exact message before when an exception was thrown in Global.asax or a PreInit and and my error handler then tried to access session. – mr_plum Mar 21 '13 at 20:55
  • Yes. We are here working with Kentico CMS and i am going to contact them for more information. – learning... Mar 21 '13 at 21:13

0 Answers0