steverguy
asked on
ASP.NET Session Error - Session State can only be used when...
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.SessionStateMod ule or a custom session state module is included in the <configuration>\<system.we b>\<httpMo dules> 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
Inherits System.Web.UI.Page
--> 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
End Sub
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!
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.SessionStateMod
when I run my category.aspx page. In my page decleration I have:
<%@ Page Language="VB" MasterPageFile="~/CatVend.
When i run category.aspx i hangs with the error above at:
Public Class category
Inherits System.Web.UI.Page
--> 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
End Sub
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!
do you have EnableSessionState="True" on your master page?
ASKER
no, just on the page that called the master page... i'll give that a try and let you know. thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It turns out I just had to move the CatID = Session("CatID") into the pageload sub. after i did that, it worked. I had the session coming in where my other declerations were.
Thanks for your help!
Thanks for your help!