Solved

ASP.NET Session Error - Session State can only be used when...

Posted on 2009-04-06
4
389 Views
Last Modified: 2012-05-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
    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!
0
Comment
Question by:steverguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:burakiewicz
ID: 24081180
do you have EnableSessionState="True" on your master page?
0
 
LVL 1

Author Comment

by:steverguy
ID: 24081298
no, just on the page that called the master page... i'll give that a try and let you know.  thanks!
0
 
LVL 16

Accepted Solution

by:
burakiewicz earned 500 total points
ID: 24081419
yeah, im thinking the master page might be overridding it
0
 
LVL 1

Author Comment

by:steverguy
ID: 24082202
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!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

615 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