ASP.NET Session Error - Session State can only be used when...
Posted on 2009-04-06
I get this 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 <configuration>\<system.web>\<httpModules> section in the application configuration.
when I run my category.aspx page. In my page decleration I have:
<%@ Page Language="VB" MasterPageFile="~/CatVend.master" AutoEventWireup="false" CodeFile="category.aspx.vb" Inherits="category" title="Untitled Page" EnableSessionState="True" %>
When i run category.aspx i hangs with the error above at:
Public Class category
--> Public CatID As Integer = CType(Session("CatID"), Integer)
I've looked online for the answer and how to change the settigns in the web.config file, but what i've tried hasn't worked.
I also setup the Session("CatID") in the Global.asax file like this:
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Session("CatID") = 0
But that didn't work. Session("CatID") gets set on a previous page - and I'm able to apply the value to it just fine. Not sure what i'm doing wrong.
Thanks for your help!