passing data between web forms

I get the following message when the second form is called

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.

enableSessionState is set to true in both form1 and form2

I have the following code in my Web.config

<system.webServer>
<modules runAllManagedModulesForAllRequests="true" >
<remove name="Session" />
<add name="Session" type="System.Web.SessionState.SessionStateModule" />

And the following code in the second form

class-id SalarySurveyWebApplication.WebFormCSE110 is partial
inherits type System.Web.UI.Page public implements type
System.Web.SessionState.IRequiresSessionState.

* $ilusing "System.Web"
* $ilusing "System"
working-storage section.

method-id NEW.
procedure division.

if (Session["TESTVAR"] not = null)
set txtComp::Text to Session["TESTVAR"]
end-if

The error occurs on the red line

Parents
  • I've never used this particular mechanism with IIS myself (that I can recall), but... The error message says you have to include SessionStateModule and set enableSessionState to true in the configuration file or the Page directive. You've shown that your web.config does the former (I'm assuming what you've done there works - haven't tried it myself), but you haven't shown us the latter. Is it possible you forgot to set enableSessionState to true?
Reply
  • I've never used this particular mechanism with IIS myself (that I can recall), but... The error message says you have to include SessionStateModule and set enableSessionState to true in the configuration file or the Page directive. You've shown that your web.config does the former (I'm assuming what you've done there works - haven't tried it myself), but you haven't shown us the latter. Is it possible you forgot to set enableSessionState to true?
Children