|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Session Variables in asp.netI've encountered a problem that is very frustrating. I'm working on a web
page and storing data in a session variable. I've done this in many other programs done with with no problems, so hitting this snag took me by surprise. I'm using VS 2008. In my current project however, the session variable I'm trying to use seems to disappear after clicking a button. I could run my query again, but that's why I use session variables to reduce hits to the database. If I access the session variable before causing the page to reload by clicking on a button, I can retrieve the value. What should I look for? Thanks, Mark Session variables will exist as long as the session does. What you just
mentioned doesn't make much sense, can you please provide your code so we can help you? Regards, -- Show quoteHide quoteAngel J. Hernández M MCP,MCAD,MCSD,MCDBA Microsoft MVP http://msmvps.com/blogs/angelhernandez *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* http://www.customware.net Tecnical Solutions Architect "Mark Brown" <mbr***@echd.org> wrote in message news:#nkNLGb9JHA.1248@TK2MSFTNGP04.phx.gbl... > I've encountered a problem that is very frustrating. I'm working on a web > page and storing data in a session variable. I've done this in many other > programs done with with no problems, so hitting this snag took me by > surprise. I'm using VS 2008. > > In my current project however, the session variable I'm trying to use > seems to disappear after clicking a button. I could run my query again, > but that's why I use session variables to reduce hits to the database. > > If I access the session variable before causing the page to reload by > clicking on a button, I can retrieve the value. > > What should I look for? > > Thanks, > Mark > > There is another possibility that involves session variables and connections
to legacy systems. IIS doesn't guarantee thread identity between pages. If your session variable creates a link to a mainframe it is possible that the link is being lost between pages. Mike Ober. Show quoteHide quote "Angel J. Hernández M." <angeljesu***@hotmail.com> wrote in message news:529447A2-3F5A-49A7-BAFA-2A5B93179DE5@microsoft.com... > Session variables will exist as long as the session does. What you just > mentioned doesn't make much sense, can you please provide your code so we > can help you? > > Regards, > > > > -- > Angel J. Hernández M > MCP,MCAD,MCSD,MCDBA > Microsoft MVP > http://msmvps.com/blogs/angelhernandez > *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* > http://www.customware.net > Tecnical Solutions Architect > > > > > > "Mark Brown" <mbr***@echd.org> wrote in message > news:#nkNLGb9JHA.1248@TK2MSFTNGP04.phx.gbl... >> I've encountered a problem that is very frustrating. I'm working on a >> web page and storing data in a session variable. I've done this in many >> other programs done with with no problems, so hitting this snag took me >> by surprise. I'm using VS 2008. >> >> In my current project however, the session variable I'm trying to use >> seems to disappear after clicking a button. I could run my query again, >> but that's why I use session variables to reduce hits to the database. >> >> If I access the session variable before causing the page to reload by >> clicking on a button, I can retrieve the value. >> >> What should I look for? >> >> Thanks, >> Mark >> >> >
Show quote
Hide quote
"Mark Brown" <mbr***@echd.org> wrote in message Two thoughts:news:%23nkNLGb9JHA.1248@TK2MSFTNGP04.phx.gbl... > I've encountered a problem that is very frustrating. I'm working on a web > page and storing data in a session variable. I've done this in many other > programs done with with no problems, so hitting this snag took me by > surprise. I'm using VS 2008. > > In my current project however, the session variable I'm trying to use > seems to disappear after clicking a button. I could run my query again, > but that's why I use session variables to reduce hits to the database. > > If I access the session variable before causing the page to reload by > clicking on a button, I can retrieve the value. > > What should I look for? 1. That you are not overwriting the session variable in some other part of your code. I'd be inclined to but a breakpoint in "Page_Unload" and see if the session variable is still defined there, that will give you a guide whether its something in your code before the Page_Unload or when the next page is loaded. 2. Less likely, but are you generating files or folders (in your www root) or doing anything else which might cause the worker process to recycle? If so then this might explain the situation if all your session data was being lost. (Solution being to switch away from in-proc.) One possible reason is you have designed the application roles and user
session and session is created single user level. So different hits could come into IIS from different user ID. So the session will be different. If you want to keep session variable available for all users, use application level session. -- Show quoteHide quoteRV "Brian Cryer" wrote: > "Mark Brown" <mbr***@echd.org> wrote in message > news:%23nkNLGb9JHA.1248@TK2MSFTNGP04.phx.gbl... > > I've encountered a problem that is very frustrating. I'm working on a web > > page and storing data in a session variable. I've done this in many other > > programs done with with no problems, so hitting this snag took me by > > surprise. I'm using VS 2008. > > > > In my current project however, the session variable I'm trying to use > > seems to disappear after clicking a button. I could run my query again, > > but that's why I use session variables to reduce hits to the database. > > > > If I access the session variable before causing the page to reload by > > clicking on a button, I can retrieve the value. > > > > What should I look for? > > Two thoughts: > > 1. That you are not overwriting the session variable in some other part of > your code. I'd be inclined to but a breakpoint in "Page_Unload" and see if > the session variable is still defined there, that will give you a guide > whether its something in your code before the Page_Unload or when the next > page is loaded. > > 2. Less likely, but are you generating files or folders (in your www root) > or doing anything else which might cause the worker process to recycle? If > so then this might explain the situation if all your session data was being > lost. (Solution being to switch away from in-proc.) > -- > Brian Cryer > www.cryer.co.uk/brian > >
VS2008 : Error Using IIF in Select Query
What are HashTables good for? winmm book? NNTP writing to file from web service [XPost] - Visual Studio 2008 - Instruct IDE Not To Generate Adapter Client Server app using winsock setting a timeout for web service response cancelling a backgroundworker "Random" numbers cause pattern? |
|||||||||||||||||||||||