SessionState won't work

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default SessionState won't work

    I have notice a couple of other threads here that depict the same problem I
    am having: I can't get session state to work.

    I wrote a component class to do all of my database access and use it in both
    Windows .net and ASP.net applications. I was dealing with it in a single
    aspx page (using codebehind) where it worked fine for this particular app.

    Now I have the instantiation in global.asax in the session_start:
    dim myDBProc as PhotoDBProcs = new PhotoDBProcs(...connection string )

    In one of the pages that uses this I have:
    dim myDBProc = ctype(Session("myDBProc"), PhotoDBProcs)

    But this gets flagged with an error saying that session state can only be
    used when enablesessionstate is set to true. I do have it set to true on
    this page as follows:
    <%@ Page Language="vb" EnableSessionState="true" AutoEventWireup="false"
    Codebehind="WebForm1.aspx.vb" Inherits="DBAPhotoQuery.WebForm1"%>

    Also my web.config file says:
    <sessionState
    mode="InProc"
    stateConnectionString="tcpip=127.0.0.1:42424"
    sqlConnectionString="data
    source=127.0.0.1;Trusted_Connection=yes"
    cookieless="false"
    timeout="20"
    />
    Any idea why this is not working
    thanks,
    Dean


    Dean Guest

  2. Similar Questions and Discussions

    1. WebService session sessionstate SOAP
      *Please* help --- I'm tearing my hair out. I want to use sessionstate in a webservice, accessed from a client, written in script (JScript,...
    2. Links don't work in Shockwave movie but work in p
      Hi, everyone: I encountered a strange problem. I downloaded a sample movie from Macromedia site and noticed that the same problem occurs what I had...
    3. Using Web.Config sessionState values
      Ok, I think I have been barking up the wrong tree here. I think my question should have been:- Can you point an <appSettings> key to the registry...
    4. Session Expired (sessionState mode="SQLServer")
      Hi All, We have developmented Web project with ASP.Net and SQL server Database. In this project we have configured "SessionState" mode as...
    5. Where does IIS and ASP.Net save Authentication info? (sessionState mode="SQLServer")
      Hi, I've successfully setup my machine to use: sessionState mode="SQLServer". All is up and running so no problems so far. Because I curious...
  3. #2

    Default Re: SessionState won't work

    I put that second line in my session_start as you advised that says:
    Session("myDBProc") = myDBProc
    and I still get exactly the same error. Since I have seen this problem
    posted before and also noticed than noone has been able to find a solution,
    I suspect that maybe this is a bug in asp.net?

    Trying something simpler I put the following into session_start:
    dim sessioninteger as integer = 4
    and tried to retrieve it from my aspx page - it came through as zero
    Then,
    I used your suggestion to follow that definition with:
    session("sessioninteger") = sessioninteger
    and it came through as 4, as it should.

    (by the way, i don't see your suggestion in any docs or books - is this an
    undocumented solution?)

    so, it seems that it will work with simple value types but not with
    something more complex.
    Not sure I know where to go from here,
    Dean



    "S. Justin Gengo" <sjgengo@aboutfortunate.com> wrote in message
    news:e5MWwMfWDHA.2268@TK2MSFTNGP11.phx.gbl...
    > Even in the global.asax you still need to place the connection into the
    > session variable.
    >
    > Change your code to include setting the session variable and it will work:
    >
    > Now I have the instantiation in global.asax in the session_start:
    > dim myDBProc as PhotoDBProcs = new PhotoDBProcs(...connection string )
    > Session("myDBProc") = myDBProc
    >
    > Sincerely,
    >
    > --
    > S. Justin Gengo, MCP
    > Web Developer
    >
    > Free code library at:
    > [url]www.aboutfortunate.com[/url]
    >
    > "Out of chaos comes order."
    > Nietzche
    > "Dean" <deanblakely@earthlink.net> wrote in message
    > news:%23L4s8weWDHA.1580@tk2msftngp13.phx.gbl...
    > > I have notice a couple of other threads here that depict the same
    problem
    > I
    > > am having: I can't get session state to work.
    > >
    > > I wrote a component class to do all of my database access and use it in
    > both
    > > Windows .net and ASP.net applications. I was dealing with it in a
    single
    > > aspx page (using codebehind) where it worked fine for this particular
    app.
    > >
    > > Now I have the instantiation in global.asax in the session_start:
    > > dim myDBProc as PhotoDBProcs = new PhotoDBProcs(...connection
    > ring )
    > >
    > > In one of the pages that uses this I have:
    > > dim myDBProc = ctype(Session("myDBProc"), PhotoDBProcs)
    > >
    > > But this gets flagged with an error saying that session state can only
    be
    > > used when enablesessionstate is set to true. I do have it set to true
    on
    > > this page as follows:
    > > <%@ Page Language="vb" EnableSessionState="true" AutoEventWireup="false"
    > > Codebehind="WebForm1.aspx.vb" Inherits="DBAPhotoQuery.WebForm1"%>
    > >
    > > Also my web.config file says:
    > > <sessionState
    > > mode="InProc"
    > > stateConnectionString="tcpip=127.0.0.1:42424"
    > > sqlConnectionString="data
    > > source=127.0.0.1;Trusted_Connection=yes"
    > > cookieless="false"
    > > timeout="20"
    > > />
    > > Any idea why this is not working
    > > thanks,
    > > Dean
    > >
    > >
    >
    >

    Dean Guest

  4. #3

    Default Re: SessionState won't work

    Ah, sorry for the last message, I got it to work as you suggested.
    In the aspx pages where I use myDBProcs, of course I had to put:
    dim myDBProc as PhotoDBProcs
    and then I had to put the following in the Initializecomponent() routine:
    myDBProc = CType(Session("myDBProc"), PhotoDBProcs)

    Before I was just doing a
    Dim myDBProc = CType(Session("myDBProc"), PhotoDBProcs)

    Thanks so much for your help, it is working ok now.
    Dean


    "S. Justin Gengo" <sjgengo@aboutfortunate.com> wrote in message
    news:e5MWwMfWDHA.2268@TK2MSFTNGP11.phx.gbl...
    > Even in the global.asax you still need to place the connection into the
    > session variable.
    >
    > Change your code to include setting the session variable and it will work:
    >
    > Now I have the instantiation in global.asax in the session_start:
    > dim myDBProc as PhotoDBProcs = new PhotoDBProcs(...connection string )
    > Session("myDBProc") = myDBProc
    >
    > Sincerely,
    >
    > --
    > S. Justin Gengo, MCP
    > Web Developer
    >
    > Free code library at:
    > [url]www.aboutfortunate.com[/url]
    >
    > "Out of chaos comes order."
    > Nietzche
    > "Dean" <deanblakely@earthlink.net> wrote in message
    > news:%23L4s8weWDHA.1580@tk2msftngp13.phx.gbl...
    > > I have notice a couple of other threads here that depict the same
    problem
    > I
    > > am having: I can't get session state to work.
    > >
    > > I wrote a component class to do all of my database access and use it in
    > both
    > > Windows .net and ASP.net applications. I was dealing with it in a
    single
    > > aspx page (using codebehind) where it worked fine for this particular
    app.
    > >
    > > Now I have the instantiation in global.asax in the session_start:
    > > dim myDBProc as PhotoDBProcs = new PhotoDBProcs(...connection
    > ring )
    > >
    > > In one of the pages that uses this I have:
    > > dim myDBProc = ctype(Session("myDBProc"), PhotoDBProcs)
    > >
    > > But this gets flagged with an error saying that session state can only
    be
    > > used when enablesessionstate is set to true. I do have it set to true
    on
    > > this page as follows:
    > > <%@ Page Language="vb" EnableSessionState="true" AutoEventWireup="false"
    > > Codebehind="WebForm1.aspx.vb" Inherits="DBAPhotoQuery.WebForm1"%>
    > >
    > > Also my web.config file says:
    > > <sessionState
    > > mode="InProc"
    > > stateConnectionString="tcpip=127.0.0.1:42424"
    > > sqlConnectionString="data
    > > source=127.0.0.1;Trusted_Connection=yes"
    > > cookieless="false"
    > > timeout="20"
    > > />
    > > Any idea why this is not working
    > > thanks,
    > > Dean
    > >
    > >
    >
    >

    Dean Guest

  5. #4

    Default Re: SessionState won't work

    Is your object PhotoDBProcs serializable?

    "Dean" <deanblakely@earthlink.net> wrote in message
    news:#L4s8weWDHA.1580@tk2msftngp13.phx.gbl...
    > I have notice a couple of other threads here that depict the same problem
    I
    > am having: I can't get session state to work.
    >
    > I wrote a component class to do all of my database access and use it in
    both
    > Windows .net and ASP.net applications. I was dealing with it in a single
    > aspx page (using codebehind) where it worked fine for this particular app.
    >
    > Now I have the instantiation in global.asax in the session_start:
    > dim myDBProc as PhotoDBProcs = new PhotoDBProcs(...connection
    ring )
    >
    > In one of the pages that uses this I have:
    > dim myDBProc = ctype(Session("myDBProc"), PhotoDBProcs)
    >
    > But this gets flagged with an error saying that session state can only be
    > used when enablesessionstate is set to true. I do have it set to true on
    > this page as follows:
    > <%@ Page Language="vb" EnableSessionState="true" AutoEventWireup="false"
    > Codebehind="WebForm1.aspx.vb" Inherits="DBAPhotoQuery.WebForm1"%>
    >
    > Also my web.config file says:
    > <sessionState
    > mode="InProc"
    > stateConnectionString="tcpip=127.0.0.1:42424"
    > sqlConnectionString="data
    > source=127.0.0.1;Trusted_Connection=yes"
    > cookieless="false"
    > timeout="20"
    > />
    > Any idea why this is not working
    > thanks,
    > Dean
    >
    >

    Jerry Guest

  6. #5

    Default Re: SessionState won't work

    If the object is in the local session storage he won’t be serialized.

    Natty Gur, CTO
    Dao2Com Ltd.
    34th Elkalay st. Raanana
    Israel , 43000
    Phone Numbers:
    Office: +972-(0)9-7740261
    Fax: +972-(0)9-7740261
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  7. #6

    Default Re: SessionState won't work

    No, It is my understanding that serializable is only needed for
    out-of-process state. In-proc should be ok for this app. Is my
    understanding correct?
    Dean
    "Jerry" <JGAO2183@rogers.com> wrote in message
    news:iYhXa.69198$hOa.10472@news02.bloor.is.net.cab le.rogers.com...
    > Is your object PhotoDBProcs serializable?
    >
    > "Dean" <deanblakely@earthlink.net> wrote in message
    > news:#L4s8weWDHA.1580@tk2msftngp13.phx.gbl...
    > > I have notice a couple of other threads here that depict the same
    problem
    > I
    > > am having: I can't get session state to work.
    > >
    > > I wrote a component class to do all of my database access and use it in
    > both
    > > Windows .net and ASP.net applications. I was dealing with it in a
    single
    > > aspx page (using codebehind) where it worked fine for this particular
    app.
    > >
    > > Now I have the instantiation in global.asax in the session_start:
    > > dim myDBProc as PhotoDBProcs = new PhotoDBProcs(...connection
    > ring )
    > >
    > > In one of the pages that uses this I have:
    > > dim myDBProc = ctype(Session("myDBProc"), PhotoDBProcs)
    > >
    > > But this gets flagged with an error saying that session state can only
    be
    > > used when enablesessionstate is set to true. I do have it set to true
    on
    > > this page as follows:
    > > <%@ Page Language="vb" EnableSessionState="true" AutoEventWireup="false"
    > > Codebehind="WebForm1.aspx.vb" Inherits="DBAPhotoQuery.WebForm1"%>
    > >
    > > Also my web.config file says:
    > > <sessionState
    > > mode="InProc"
    > > stateConnectionString="tcpip=127.0.0.1:42424"
    > > sqlConnectionString="data
    > > source=127.0.0.1;Trusted_Connection=yes"
    > > cookieless="false"
    > > timeout="20"
    > > />
    > > Any idea why this is not working
    > > thanks,
    > > Dean
    > >
    > >
    >
    >

    Dean Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139