enableSessionState - still struggling

Discussion in 'ASP .Net' started by Martin, Dec 26, 2003.

  1. Martin

    Martin Guest

    Hi,

    I had a page the other day for which the compiler just wouldn't recognize
    the fact that I had enabled session state in every possible way. I ended up
    moving the code that dealt with the Session object from code-behind to
    in-page and it worked. Didn't find an explanation though but it got me up
    again.

    Today it got worse. Now what sense does this make:

    <%@ Page Language="VBScript" EnableSessionState="True" Debug="True" %>
    <%
    Session.Abandon
    %>

    Above is the entire aspx-page (saved with an aspx extansion). Can't get much
    simpler than this, right? It gives me the horrifying "Session state can only
    be used when enableSessionState is set to true, either in a configuration
    file or in the Page directive".

    Both machine.config and my application's web.config file have
    enableSessionState set to "true", which should be the default anyway. I am
    using this version:

    Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
    Version:1.1.4322.573

    Please help me.

    Martin.
     
    Martin, Dec 26, 2003
    #1
    1. Advertising

  2. Martin

    Hermit Dave Guest

    Martin i atually havent the slightest clue as to y its happening but why do
    you have
    <%@Page Language="VBScript"
    there is not VBScript in aspx any more...
    <%@Page Language="VB"

    and just use web.config file in the app dir for your application based
    session state config
    <!-- SESSION STATE SETTINGS
    By default ASP.NET uses cookies to identify which requests belong
    to a particular session.
    If cookies are not available, a session can be tracked by adding a
    session identifier to the URL.
    To disable cookies, set sessionState cookieless="true".
    -->
    <sessionState
    mode="InProc"
    stateConnectionString="tcpip=127.0.0.1:42424"
    sqlConnectionString="data
    source=127.0.0.1;Trusted_Connection=yes"
    cookieless="false"
    timeout="20"
    />

    hope this helps,

    HD

    "Martin" <> wrote in message
    news:3fec6a9c$0$143$4all.nl...
    > Hi,
    >
    > I had a page the other day for which the compiler just wouldn't recognize
    > the fact that I had enabled session state in every possible way. I ended

    up
    > moving the code that dealt with the Session object from code-behind to
    > in-page and it worked. Didn't find an explanation though but it got me up
    > again.
    >
    > Today it got worse. Now what sense does this make:
    >
    > <%@ Page Language="VBScript" EnableSessionState="True" Debug="True" %>
    > <%
    > Session.Abandon
    > %>
    >
    > Above is the entire aspx-page (saved with an aspx extansion). Can't get

    much
    > simpler than this, right? It gives me the horrifying "Session state can

    only
    > be used when enableSessionState is set to true, either in a configuration
    > file or in the Page directive".
    >
    > Both machine.config and my application's web.config file have
    > enableSessionState set to "true", which should be the default anyway. I am
    > using this version:
    >
    > Version Information: Microsoft .NET Framework Version:1.1.4322.573;

    ASP.NET
    > Version:1.1.4322.573
    >
    > Please help me.
    >
    > Martin.
    >
    >
     
    Hermit Dave, Dec 26, 2003
    #2
    1. Advertising

  3. Martin

    Alvin Bruney Guest

    i've copied and pasted your simple page into a new project. i don't get that
    error. can you give more informatiton on this? It seems to be specific to a
    setting on your computer and not to the framework or the environment
    otherwise i would be getting it as well. Makes sense?

    --
    Regards,
    Alvin Bruney
    Got DotNet? Get it here
    http://home.networkip.net/dotnet/tidbits/default.htm
    "Martin" <> wrote in message
    news:3fec6a9c$0$143$4all.nl...
    > Hi,
    >
    > I had a page the other day for which the compiler just wouldn't recognize
    > the fact that I had enabled session state in every possible way. I ended

    up
    > moving the code that dealt with the Session object from code-behind to
    > in-page and it worked. Didn't find an explanation though but it got me up
    > again.
    >
    > Today it got worse. Now what sense does this make:
    >
    > <%@ Page Language="VBScript" EnableSessionState="True" Debug="True" %>
    > <%
    > Session.Abandon
    > %>
    >
    > Above is the entire aspx-page (saved with an aspx extansion). Can't get

    much
    > simpler than this, right? It gives me the horrifying "Session state can

    only
    > be used when enableSessionState is set to true, either in a configuration
    > file or in the Page directive".
    >
    > Both machine.config and my application's web.config file have
    > enableSessionState set to "true", which should be the default anyway. I am
    > using this version:
    >
    > Version Information: Microsoft .NET Framework Version:1.1.4322.573;

    ASP.NET
    > Version:1.1.4322.573
    >
    > Please help me.
    >
    > Martin.
    >
    >
     
    Alvin Bruney, Dec 26, 2003
    #3
  4. Martin

    Martin Guest

    > there is not VBScript in aspx any more...

    Oh, well... Remnants of the pre-.NET era. I changed it to VB. Usually the
    compiler gives me "xxx no longer supported but in this case it didn't mind.

    > and just use web.config file in the app dir for your application based
    > session state config
    > <!-- SESSION STATE SETTINGS
    > By default ASP.NET uses cookies to identify which requests belong
    > to a particular session.
    > If cookies are not available, a session can be tracked by adding a
    > session identifier to the URL.
    > To disable cookies, set sessionState cookieless="true".
    > -->
    > <sessionState
    > mode="InProc"
    > stateConnectionString="tcpip=127.0.0.1:42424"
    > sqlConnectionString="data
    > source=127.0.0.1;Trusted_Connection=yes"
    > cookieless="false"
    > timeout="20"
    > />


    This section wasn't in web.config, the default in machine.config should
    apply. I added it in web.config and tried it cookieless. No difference. I
    believe this section primarily enables you to use centralized out-of-server
    state management. Default on-server state management is okay for me.

    > hope this helps,


    Apart from making me feel a little better knowing there's folk out there
    thinking with me, not really yet. :)
     
    Martin, Dec 26, 2003
    #4
  5. Martin

    Martin Guest

    > i've copied and pasted your simple page into a new project. i don't get
    that error.

    That is good to know, thank you.

    > can you give more informatiton on this? It seems to be specific to a
    > setting on your computer and not to the framework or the environment
    > otherwise i would be getting it as well. Makes sense?


    About a week ago another guy posted the same problem. Neither of us had
    found anything on the matter so it does make sense to assume it is some
    local problem. I have it on both my machines though, a Windows Server 2003
    and a Windows XP Professional system (to which I copied the lot just to see
    the response).

    Another page in the same application does allow me to address the session
    object. Do I however put the line that increments a session variable all the
    way up, making it the first statement in the page, then it fails again (the
    succeeding line is in a post-back section further down).

    Still flabbergastered.

    Martin.

    > > Hi,
    > >
    > > I had a page the other day for which the compiler just wouldn't

    recognize
    > > the fact that I had enabled session state in every possible way. I ended

    up
    > > moving the code that dealt with the Session object from code-behind to
    > > in-page and it worked. Didn't find an explanation though but it got me

    up
    > > again.
    > >
    > > Today it got worse. Now what sense does this make:
    > >
    > > <%@ Page Language="VBScript" EnableSessionState="True" Debug="True" %>
    > > <%
    > > Session.Abandon
    > > %>
    > >
    > > Above is the entire aspx-page (saved with an aspx extansion). Can't get

    much
    > > simpler than this, right? It gives me the horrifying "Session state can

    only
    > > be used when enableSessionState is set to true, either in a

    configuration
    > > file or in the Page directive".
    > >
    > > Both machine.config and my application's web.config file have
    > > enableSessionState set to "true", which should be the default anyway. I

    am
    > > using this version:
    > >
    > > Version Information: Microsoft .NET Framework Version:1.1.4322.573;

    ASP.NET
    > > Version:1.1.4322.573
    > >
    > > Please help me.
    > >
    > > Martin.
    > >
    > >

    >
    >
     
    Martin, Dec 26, 2003
    #5
  6. Martin

    Alvin Bruney Guest

    You might want to open up a trouble ticket with microsoft so they can take a
    memory dump of your system to see what's wrong.

    Either you use this option or it's trial and error which burns a lot of
    time. I'm running xp pro with frame 1.1 and it works smoothely here. The
    link to microsoft provides you with 3, free trouble tickets to use anyway
    you please. After they are used up, your are charged per ticket so use
    wisely.

    Here is a link:
    http://support.microsoft.com/default.aspx?scid=fh;[ln];oasoem

    --
    Regards,
    Alvin Bruney
    Got DotNet? Get it here
    http://home.networkip.net/dotnet/tidbits/default.htm
    "Martin" <> wrote in message
    news:3feca9b4$0$149$4all.nl...
    > > i've copied and pasted your simple page into a new project. i don't get

    > that error.
    >
    > That is good to know, thank you.
    >
    > > can you give more informatiton on this? It seems to be specific to a
    > > setting on your computer and not to the framework or the environment
    > > otherwise i would be getting it as well. Makes sense?

    >
    > About a week ago another guy posted the same problem. Neither of us had
    > found anything on the matter so it does make sense to assume it is some
    > local problem. I have it on both my machines though, a Windows Server 2003
    > and a Windows XP Professional system (to which I copied the lot just to

    see
    > the response).
    >
    > Another page in the same application does allow me to address the session
    > object. Do I however put the line that increments a session variable all

    the
    > way up, making it the first statement in the page, then it fails again

    (the
    > succeeding line is in a post-back section further down).
    >
    > Still flabbergastered.
    >
    > Martin.
    >
    > > > Hi,
    > > >
    > > > I had a page the other day for which the compiler just wouldn't

    > recognize
    > > > the fact that I had enabled session state in every possible way. I

    ended
    > up
    > > > moving the code that dealt with the Session object from code-behind to
    > > > in-page and it worked. Didn't find an explanation though but it got me

    > up
    > > > again.
    > > >
    > > > Today it got worse. Now what sense does this make:
    > > >
    > > > <%@ Page Language="VBScript" EnableSessionState="True" Debug="True" %>
    > > > <%
    > > > Session.Abandon
    > > > %>
    > > >
    > > > Above is the entire aspx-page (saved with an aspx extansion). Can't

    get
    > much
    > > > simpler than this, right? It gives me the horrifying "Session state

    can
    > only
    > > > be used when enableSessionState is set to true, either in a

    > configuration
    > > > file or in the Page directive".
    > > >
    > > > Both machine.config and my application's web.config file have
    > > > enableSessionState set to "true", which should be the default anyway.

    I
    > am
    > > > using this version:
    > > >
    > > > Version Information: Microsoft .NET Framework Version:1.1.4322.573;

    > ASP.NET
    > > > Version:1.1.4322.573
    > > >
    > > > Please help me.
    > > >
    > > > Martin.
    > > >
    > > >

    > >
    > >

    >
    >
     
    Alvin Bruney, Dec 27, 2003
    #6
  7. Martin

    Martin Guest

    Hi,

    Fixed it. When I renamed web.config I had my session again. Further
    investigation brought it down to this:

    <configuration>
    <system.web>
    <httpModules>
    <!-- <add name="Session"
    type="System.Web.SessionState.SessionStateModule"/> -->
    </httpModules>
    </system.web>
    </configuration>

    There are other entries for OutputCache and WindowsAuthentication left out
    for brevity). For some reason the session module declaration was commented
    out. I can't remember doing that nor why on earth I would want to but it is
    likely that I did it myself at some point. It also works now with the
    shotcut "Session" instead of "System.Web.HttpContext.Current.Session", even
    in code-behind.

    That is one problem solved. Now I still have to make the session events
    (Session_OnStart and Session_OnEnd) kick in. As it is they don't and I do
    not see why.

    Martin.



    "Martin" <> wrote in message
    news:3fef3ec4$0$137$4all.nl...
    > Hi,
    >
    > > You might want to open up a trouble ticket with microsoft so they can

    take
    > a
    > > memory dump of your system to see what's wrong.

    >
    > That seems rather drastic. Fortunately it's not for a mission-critical web
    > application, I'm only getting proficient with the technology here. And I
    > think I got one step further.
    >
    > It I change my code to
    >
    > <%@ Page Language="VBScript" EnableSessionState="True" Debug="True" %>
    >
    > <%
    > System.Web.HttpContext.Current.Session.Abandon
    > %>
    >
    > I get a different error:
    >
    > Exception Details: System.NullReferenceException: Object reference not set
    > to an instance of an object.
    >
    > So it seems to be a context problem and the initial error messages about
    > enableSessionState was total baloney.
    >
    > It appears that Current (a static member of HttpContext of type

    HttpContext)
    > is a valid object and that its Session member returns null. Now that isn't
    > right, is it?
    >
    > So, did I find a bug? I think I did, I should always have a session.
    > Apperently on my system ASP.NET has no session for me when I need it.
    > Moreover, neither Session_OnStart or Session_OnEnd appears to be called.

    Now
    > what to think of that? I even renamed them to Session_Start and

    Session_End
    > to no avail (some examples use these names instead and I still don't
    > understand how application events get wired up but that's another matter),
    >
    > Does this ring a bell with anyone?
    >
    > Martin.
    >
    >
    > > Here is a link:
    > > http://support.microsoft.com/default.aspx?scid=fh;[ln];oasoem
    > >
    > > --
    > > Regards,
    > > Alvin Bruney
    > > Got DotNet? Get it here
    > > http://home.networkip.net/dotnet/tidbits/default.htm
    > > "Martin" <> wrote in message
    > > news:3feca9b4$0$149$4all.nl...
    > > > > i've copied and pasted your simple page into a new project. i don't

    > get
    > > > that error.
    > > >
    > > > That is good to know, thank you.
    > > >
    > > > > can you give more informatiton on this? It seems to be specific to a
    > > > > setting on your computer and not to the framework or the environment
    > > > > otherwise i would be getting it as well. Makes sense?
    > > >
    > > > About a week ago another guy posted the same problem. Neither of us

    had
    > > > found anything on the matter so it does make sense to assume it is

    some
    > > > local problem. I have it on both my machines though, a Windows Server

    > 2003
    > > > and a Windows XP Professional system (to which I copied the lot just

    to
    > > > see the response).
    > > >
    > > > Another page in the same application does allow me to address the

    > session
    > > > object. Do I however put the line that increments a session variable

    all
    > the
    > > > way up, making it the first statement in the page, then it fails again

    > (the
    > > > succeeding line is in a post-back section further down).
    > > >
    > > > Still flabbergastered.
    > > >
    > > > Martin.
    > > >
    > > > > > Hi,
    > > > > >
    > > > > > I had a page the other day for which the compiler just wouldn't
    > > > > > recognize the fact that I had enabled session state in every
    > > > > > possible way. I ended up moving the code that dealt with the
    > > > > > Session object from code-behind to in-page and it worked.
    > > > > > Didn't find an explanation though but it got me up again.
    > > > > >
    > > > > > Today it got worse. Now what sense does this make:
    > > > > >
    > > > > > <%@ Page Language="VBScript" EnableSessionState="True"

    Debug="True"
    > %>
    > > > > > <%
    > > > > > Session.Abandon
    > > > > > %>
    > > > > >
    > > > > > Above is the entire aspx-page (saved with an aspx extansion).
    > > > > > Can't get much simpler than this, right? It gives me the
    > > > > > horrifying "Session state can only be used when enableSessionState
    > > > > > is set to true, either in a configuration file or in the Page

    > directive".
    > > > > >
    > > > > > Both machine.config and my application's web.config file have
    > > > > > enableSessionState set to "true", which should be the default
    > > > > > anyway. I am using this version:
    > > > > >
    > > > > > Version Information: Microsoft .NET Framework

    Version:1.1.4322.573;
    > > > > > ASP.NET Version:1.1.4322.573
    > > > > >
    > > > > > Please help me.
    > > > > >
    > > > > > Martin.

    > >

    >
    >
     
    Martin, Dec 29, 2003
    #7
    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. Marco Gerlach
    Replies:
    2
    Views:
    6,525
    Marco Gerlach
    Jul 18, 2003
  2. Jim Cheshire [MSFT]
    Replies:
    3
    Views:
    2,345
    Jim Cheshire [MSFT]
    Aug 4, 2003
  3. John Baughman
    Replies:
    6
    Views:
    13,191
    Natty Gur
    Dec 24, 2003
  4. Jeffry van de Vuurst
    Replies:
    0
    Views:
    2,149
    Jeffry van de Vuurst
    May 18, 2004
  5. Stef Mientki
    Replies:
    12
    Views:
    439
    Gabriel Genellina
    Jan 7, 2007
Loading...

Share This Page