Solved

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

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Google Maps with Webforms 1 45
How can I do Unit Testing with Session ? 1 41
ASP.net Markup for Sub Menu 2 65
Javascript function 3 22
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…

752 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