[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive

Posted on 2007-07-26
9
Medium Priority
?
1,200 Views
Last Modified: 2008-05-07
Hi,
I am getting an error message when I tried to execute the following line of code

private void Page_Load(object sender, System.EventArgs e)
{
      authentification objAuthentification = (authentification)this.Session["membre"];

      if(objAuthentification == null)
      {
        Response.Redirect("login.aspx", true);        
      }
      else
      {
        if (!objAuthentification.successCode)
        {
          Response.Redirect("login.aspx", true);
        }
      }
}

The error is:
[HttpException (0x80004005): Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive]
   System.Web.UI.Page.get_Session() +146
   main.membres.accueilMembres.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\main\membres\membres.aspx.cs:24

and line 24 refers to authentification objAuthentification = (authentification)this.Session["membre"];

This is weird since it worked on my development machine. It just doesn't work on the web server machine. Anyone knows why?

Thanks
0
Comment
Question by:TungVan
  • 4
  • 3
8 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 19580130
open your web.config file and add the attribute
enableSessionState="true".  It would then look something like this:

     <sessionState
            mode="InProc"
            enableSessionState="true"
            stateConnectionString="tcpip=127.0.0.1:42424"
            sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
            cookieless="false"
            timeout="20"
    />

Hope this helps,
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 19580136
look for
<%@ ... Page EnableSessionState="true" ... %>
in <yourpage>.aspx
0
 

Author Comment

by:TungVan
ID: 19588256
Hi Dhaest,
I tried your solution.I put enableSessionState="true"in webcconfig and all my aspx pages. It still doesn't work.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 53

Expert Comment

by:Dhaest
ID: 19590249
Are your IIS-settings on your development machine the same as on your production ?
0
 

Author Comment

by:TungVan
ID: 19606129
I don't have direct access to my web server. What IIS-settings should I look at? (i will ask the web admin to send me those screenshots).
0
 

Accepted Solution

by:
TungVan earned 0 total points
ID: 19628281
I found my problem. It was because I put httpmodule <clear> in my webconfig.
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 19933601
Don't forget to close this question
http://www.experts-exchange.com/help.jsp#hs5
0
 
LVL 1

Expert Comment

by:Vee_Mod
ID: 20092251
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Loops Section Overview
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question