Solved

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

Posted on 2009-04-06
4
376 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now