ASP.NET Commander Page

Posted on 2005-05-09
Medium Priority
Last Modified: 2010-04-07
I am in the process of building a commander page for my ASP.NET application.  

The commander page is a class that inherits "System.Web.UI.Page"

Then, on webforms within my application, rather than inheriting "System.Web.UI.Page" on the forms, I inherit my commander page.

This works great, up until I try to access Session variables from my commander class.

I've tried several variations, and I keep getting the following error:

"Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive"

Keep in mind, that Session State is ENABLED, and works fine from other locations.  I think this has to do with an order in which the code is being executed but not quite sure.

Any help would be greatly appreciated.

Question by:mmarksbury
  • 3
  • 2
LVL 33

Expert Comment

ID: 13961593
I do this all the time, and I've never ran into a problem with the session.  Can you post the source of this page?

Author Comment

ID: 13961625
using System;
using System.Data;
using System.Configuration;

namespace MyApp.BLL
      public abstract class AdminPage : System.Web.UI.Page
            private int      _UserId;
            public AdminPage()
                                                _UserId = Convert.ToInt32(this.Session["UserId"]);
                  System.Web.UI.WebControls.Literal PL = new System.Web.UI.WebControls.Literal();
                  PL.Text = _UserId.ToString();
LVL 33

Accepted Solution

raterus earned 2000 total points
ID: 13961654
You shouldn't be defining your own constructor in this page, rather you should use the normal events of the asp.net page lifecycle to do things.  For example, the code you have looks like it would be better placed in page_init.


Author Comment

ID: 13961674
an example ?

Author Comment

ID: 13961689
Nevermind, I got it.  Thanks

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

862 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