views:

97

answers:

1

hi

i have an application wherein i am accessing the Session object in the CommonCode.cs file that resides in the App_Code folder. But when the session object is accessed the application throws me an 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 \\ section in the application configuration.

Now i have already enabled the session state property in the web.config file, here is my code from the web.config file:

<pages enableSessionState="true" autoEventWireup="true">
    <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </controls>
</pages>

I dont understand why am i still getting that error !! please help !

thanks a lot.

+1  A: 

hey,

i solved my own query for the very first time over here.

Brief answer:

I was trying to access the session variable in the Page Load and it is not loaded until then...

Details for the solution to my above mentioned problem can be found here:

http://weblogs.asp.net/anasghanem/archive/2008/05/07/avoid-using-the-session-in-the-page-constructor.aspx

Thanks anyways people!

Shrewd Demon