Session State not maintained asp.net 2.0

Discussion in 'ASP .Net' started by =?Utf-8?B?SXVsaWFu?=, Mar 27, 2006.

  1. I must be doing something fundamentally wrong here. This is what I have in
    web.config:

    <sessionState cookieName="SOMENAME" mode="InProc"
    stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data
    source=127.0.0.1;user id=sa;password="
    cookieless="false" timeout="15" />
    <globalization requestEncoding="ISO-8859-1"
    responseEncoding="ISO-8859-1" />
    <pages theme="DefaultTheme" enableSessionState="true"
    enableViewState="true" enableViewStateMac="true" validateRequest="true" />

    I also set the EnableSessionState on the pages explicitly. In one of the
    pages I have this code:

    protected void Page_Load(object sender, EventArgs e)
    {
    if (Session["AAAAA"] == null)
    {
    Session["AAAAA"] = 0;
    }
    else
    {
    Session["AAAAA"] = (int)Session["AAAAA"] + 1;
    }
    }

    If I keep refreshing this page, the Session ID is always different and the
    Session.IsNewSession is always true. Even though I can see that the value of
    0 is set, on every request the session is regenerated... Why would that
    happen?

    Thank you,

    Iulian


    --
    Regards,

    Iulian
    =?Utf-8?B?SXVsaWFu?=, Mar 27, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?SXVsaWFu?=

    Vivek N Guest

    Well I guess you need to add the GLOBAL.ASAX file in the root directory
    of your website.
    This is not automatocally added noe in VS.Net 2005 and so you need to
    add this manually.

    Add New Item --> Global.asax

    You don't need to wirte any code. But I hope this should help you out.

    Vivek N
    MCAD
    Vivek N, Mar 27, 2006
    #2
    1. Advertising

  3. RE: Session State not maintained asp.net 2.0 [Solved]

    Ok, I solved it, apparently this was causing the problem:

    <sessionState [...] />

    Once I removed it from web.config it started to work. This was a
    reminescence of the asp 1.1 application and I assume it conflicts with 2.0...

    --
    Regards,

    Iulian


    "Iulian" wrote:

    > I must be doing something fundamentally wrong here. This is what I have in
    > web.config:
    >
    > <sessionState cookieName="SOMENAME" mode="InProc"
    > stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data
    > source=127.0.0.1;user id=sa;password="
    > cookieless="false" timeout="15" />
    > <globalization requestEncoding="ISO-8859-1"
    > responseEncoding="ISO-8859-1" />
    > <pages theme="DefaultTheme" enableSessionState="true"
    > enableViewState="true" enableViewStateMac="true" validateRequest="true" />
    >
    > I also set the EnableSessionState on the pages explicitly. In one of the
    > pages I have this code:
    >
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > if (Session["AAAAA"] == null)
    > {
    > Session["AAAAA"] = 0;
    > }
    > else
    > {
    > Session["AAAAA"] = (int)Session["AAAAA"] + 1;
    > }
    > }
    >
    > If I keep refreshing this page, the Session ID is always different and the
    > Session.IsNewSession is always true. Even though I can see that the value of
    > 0 is set, on every request the session is regenerated... Why would that
    > happen?
    >
    > Thank you,
    >
    > Iulian
    >
    >
    > --
    > Regards,
    >
    > Iulian
    =?Utf-8?B?SXVsaWFu?=, Mar 28, 2006
    #3
    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. jnickfl1
    Replies:
    0
    Views:
    553
    jnickfl1
    Sep 18, 2006
  2. Santel

    Selected state not maintained on postback

    Santel, Jun 12, 2007, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    895
    Teemu Keiski
    Jun 13, 2007
  3. jmhmaine
    Replies:
    0
    Views:
    277
    jmhmaine
    Jan 20, 2005
  4. jmhmaine
    Replies:
    2
    Views:
    294
    Steven Cheng[MSFT]
    Jan 21, 2005
  5. Saville Kaufman

    Session.session not maintained

    Saville Kaufman, Jul 23, 2004, in forum: ASP General
    Replies:
    4
    Views:
    116
    Egbert Nierop \(MVP for IIS\)
    Jul 24, 2004
Loading...

Share This Page