0

Is there any reason why Session related code throws a SessionState exception while other parts of a site does not? Everything worked previously, but it seems a change has taken place somewhere. I'm not sure which setting in IIS or elsewhere would resolve it.

Here is the error:

System.Web.HttpException (0x80004005): 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 \ section in the application configuration. at System.Web.UI.Page.get_Session() at MRG.Page_Load(Object sender, EventArgs e) in ....\MRG.master.cs:line 45

Here is MRG.master.cs:line 45:

if (Session["myID"] != null)

   ...

Here is the Global.asax session entry that worked with no errors:

   void Session_Start(object sender, EventArgs e)
    {
        Identity visitor = new Identity("abcde");
        Session["myID"] = visitor;
    }

Also, here is the web.config entry that also worked before on another site:

<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" cookieless="false" timeout="120"/>
  • "Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive". Does your config file or page contain this? – ADyson Jan 24 '18 at 21:38
  • Possible duplicate of [Session state can only be used when enableSessionState is set to true either in a configuration](https://stackoverflow.com/questions/14334147/session-state-can-only-be-used-when-enablesessionstate-is-set-to-true-either-in) – ADyson Jan 24 '18 at 21:39

0 Answers0