problem with SessionState

Discussion in 'ASP .Net' started by Craig G, Jan 27, 2005.

  1. Craig G

    Craig G Guest

    i have the code in the Page_load event of a toolbar (usercontrol)

    If Not Page.IsPostBack Then

    If Session("SecurityInfo") Is Nothing Then
    Response.Redirect("Default.aspx")
    End If

    lblUserName.Text = Session.Item("SecurityInfo").UserFullName
    lblUserRole.Text = Session.Item("SecurityInfo").Role

    subFillProfessionCombo()

    RaiseEvent SecurityDetailsLoaded()

    Dim strName As Array
    strName = Split(Request.ServerVariables("URL").ToString(), "/")
    Session("CurrentPage") = strName(UBound(strName))
    End If

    every so often it falls over on

    If Session("SecurityInfo") Is Nothing Then
    Response.Redirect("Default.aspx")
    End If

    and returns the following error

    Run-time exception thrown : System.Web.HttpException - Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive

    i'm kinda baffled as to why its only falling over sometimes and other times it works fine. and i dont know where to set enableSessionState = true
     
    Craig G, Jan 27, 2005
    #1
    1. Advertising

  2. Craig,

    you can enable Session state on every single page. Simply set the property
    EnableSessionState to true. You can do so using the designer or by code.
    Another option is to enable session state for all pages. Open web.config and
    go to the <pages> - configuration element. Simply add the attribute
    enableSessionState="true" to it:

    <pages enableSessionState="true" ...>

    Regards,
    Michael

    "Craig G" <craig.gamble@y_arrasoftware.com> schrieb im Newsbeitrag
    news:e3f$...
    i have the code in the Page_load event of a toolbar (usercontrol)

    If Not Page.IsPostBack Then
    If Session("SecurityInfo") Is Nothing Then
    Response.Redirect("Default.aspx")
    End If
    lblUserName.Text = Session.Item("SecurityInfo").UserFullName
    lblUserRole.Text = Session.Item("SecurityInfo").Role
    subFillProfessionCombo()
    RaiseEvent SecurityDetailsLoaded()
    Dim strName As Array
    strName = Split(Request.ServerVariables("URL").ToString(), "/")
    Session("CurrentPage") = strName(UBound(strName))
    End If
    every so often it falls over on
    If Session("SecurityInfo") Is Nothing Then
    Response.Redirect("Default.aspx")
    End If

    and returns the following error

    Run-time exception thrown : System.Web.HttpException - Session state can
    only be used when enableSessionState is set to true, either in a
    configuration file or in the Page directive

    i'm kinda baffled as to why its only falling over sometimes and other times
    it works fine. and i dont know where to set enableSessionState = true
     
    Michael Groeger, Jan 27, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Flemming Jensen
    Replies:
    0
    Views:
    357
    Flemming Jensen
    Aug 22, 2003
  2. Scott M.

    Re: Wierd SessionState Problem

    Scott M., Aug 30, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    422
    Scott M.
    Aug 30, 2003
  3. Dean
    Replies:
    1
    Views:
    369
  4. Mikko Penkkimäki

    SessionState timeout problem

    Mikko Penkkimäki, Sep 6, 2004, in forum: ASP .Net
    Replies:
    8
    Views:
    43,756
  5. Phl
    Replies:
    0
    Views:
    386
Loading...

Share This Page