views:

30

answers:

1

Hi, I am using a page base in my web application where the page base will be called before the page load of every page.

I plan to check if the if the user is valid by checking the value in session state.

But i am getting an error message saying

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 `

So is it possible to read the session values from the page base.

Added the code

public class PageBase : System.Web.UI.Page
{
    public PageBase()
    {
        if (Session["UserID"] == null)
        {
            Response.Redirect("Home.aspx", false);       
        }
    }
}

Thanks, Jebli

+2  A: 
leppie
As early as possible... init?
CRice
@CRice: Anywhere after the Session variable has been initialized and loaded/init'd on the page. Page load is normally safest.
leppie