Session state can only be used when enableSessionState is set to true

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.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: 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.

This error usually occurs when you have declared an object variable public to the page and it access a Session variable, example:

Partial Class _Default

Inherits System.Web.UI.Page

Private m As New DBAccess(Session(“dbname”))

Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load

End Sub

End Class

just rewrite the above code to look like as below
Partial Class _Default
Inherits System.Web.UI.Page
Private m As DBAccess
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
m =New DBAccess(Session(“dbname”))
End Sub
End Class


, ,

  1. #1 by Sajjad on May 19th, 2011 - 2:19 pm

    Thanks, it is working and plz keep it up.
    Sajjad Yousuf Anjum
    from Pakistan.

(will not be published)
Submit Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Subscribe to comments feed
  1. No trackbacks yet.

SetPageWidth