Print Page | Close Window

Session state

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=10130
Printed Date: 28 March 2026 at 11:07pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Session state
Posted By: Mart
Subject: Session state
Date Posted: 24 April 2004 at 4:29pm
Hi guys,

I am trying to use the session state in an applicaton. But the problem is that when I try to do

Private Host As String = Session("Server")

I get the following error:

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

So then I changed the session region of my web.config from:
<sessionState
         &nbs p;  mode="InProc"
         &nbs p;  stateConnectionString="tcpip=127.0.0.1:42424"
         &nbs p;  sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
         &nbs p;  cookieless="true"
         &nbs p;  timeout="20"
    />

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

But then I get the following error:

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Unrecognized attribute 'enableSessionState'.

Source Error:

Line 70:           To disable cookies, set sessionState cookieless="true".
Line 71: -->
Line 72: <sessionState
Line 73: enableSessionState="true"
Line 74: mode="InProc"

Can anyone shine some light on the subject? Thanks, Mart.



Replies:
Posted By: Mart
Date Posted: 24 April 2004 at 4:34pm
P.s. It doesn't work if I put it in the page directive either... Seems to ignore it.


Posted By: Diep-Vriezer
Date Posted: 02 May 2004 at 4:23am

<%@ Page Language="VB" EnableSessionState="True" %> Doesn't work? Wtf?

I read this somewhere

Use System.Web.HttpContext.Current.Session to refer to the session instance for the current http request instead of the Session Keyword.
System.Web.HttpContext.Current.Session provides you with the System.Web.HttpSessionState instance for the current HTTP request.

http://www.visual-basic-data-mining.net/Forum/showpost.aspx?PostID=1373 - http://www.visual-basic-data-mining.net/Forum/showpost.aspx? PostID=1373



-------------
Gone..



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net