Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-04-06
4
Medium Priority
?
392 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

719 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