Session variables lost between page requests

Hi

We're getting a problem where session variables are lost between page requests. I set a session variable (affilaite id) when a session starts in session_start event in global.asax. With tracing enabled i can see that this variable is resident on the initial page request. When i navigate to a new page however, all session variables are lost.

This has only just started happening fairly recently and I cannot find any particular piece of code that may be causing it. I've read stuff on the web about worker process recycling but if this is happening every time the user requests a page then somethings seriously wrong.

This is happening on 2 XP development machines and a Win2K3 server machine.

Any ideas

Ben

0
Egdif
1/11/2007 10:34:32 PM
asp.net.state-management 8807 articles. 0 followers. Follow

4 Replies
809 Views

Similar Articles

[PageSpeed] 43
Get it on Google Play
Get it on Apple App Store

Can you provide a few more details, please.

Firstly, what session state store are you using? My guess would be inproc, but can you confirm that by checking in web.config.

Secondly, are you using cookie-based sessions? Can you confirm (via tracing) that the cookie is being sent from the client to the server?

Thirdly, have you set a breakpoint on your Session_Start event handler and then tested that it gets hit on every request. It should do if the session is being lost.

Next, have you any code that calls Session.Abandon()? Or any code in, say, a master page or base page class that might inadvertently be resetting the session variables?

Given that the problem is occurring on all the machines, the most likely cause is a configuration/coding error. It is unlikely to be a worker process recycling problem on a simple XP development machine, and it certainly shouldn't be occurring on every page request.

Finally, have you tried adding two test pages, one of which simply sets a value into a Session variable and then calls Response.Redirect to the second page which displays the variable? Proving that this works is indicative that the problem lies within your code, and will also provide an excellent (and small) testing ground to isolate the problem.

 

 


Regards

Dave
0
DMW
1/12/2007 1:43:30 AM

Hi

Thanks for the response. Here's the answers to your questions:

1) We're using InProc

2) Yes we are using cookie based sessions and the session cookie is present across al requests

3) Session_Start is hit on every request

4) We don't call Session.Abort() anywhere

5) Using the two test pages did work.

So it's safe to assume that it's the code. Any suggestions on tracking it down?

Thanks for your help

Ben

0
Egdif
1/12/2007 7:33:58 PM

An interesting observation while trying to debug this:

When the inital page loads and the user navigates to another page using a hyperlink, session_start is fired once. If they navigate away using anything that causes a postback (Button, ImageButton) and whose handler calls response.redirect, session_start is called twice. Once they've navigated away once from the main page however, all subsequent navigation, whether by postback/response.redirect or using plain hyperlink, DOES NOT fire session_start.

I've tried changing the initial start page to something other than default.aspx and the problem occurs for some pages but not others. I can't see any obvious difference between them in terms of functionality. For example, default.aspx has no C# code otehr than an empty Page_Load handler.

All pages share a common base page however that override OnPreInit and OnLoad virtual methods but commenting these out doesn't fix the problem.

Putting a breakpoint on session_start, the opening the initial page (default.aspx) on a new debugging session shows the following call stack: 

ConciergeDesk.Site.Shop.DLL!ConciergeDesk.Site.Shop.Global.Session_Start(object sender = {System.Web.SessionState.SessionStateModule}, System.EventArgs e = {System.EventArgs}) Line 27 C#
  System.Web.dll!System.Web.SessionState.SessionStateModule.RaiseOnStart(System.EventArgs e) + 0x8c bytes 
  System.Web.dll!System.Web.SessionState.SessionStateModule.CompleteAcquireState() + 0x9b bytes 
  System.Web.dll!System.Web.SessionState.SessionStateModule.BeginAcquireState(object source, System.EventArgs e, System.AsyncCallback cb, object extraData) + 0x21f bytes 
  System.Web.dll!System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() + 0x5b bytes 
  System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step = {System.Web.HttpApplication.AsyncEventExecutionStep}, ref bool completedSynchronously = true) + 0x9c bytes 
  System.Web.dll!System.Web.HttpApplication.ResumeSteps(System.Exception error) + 0x163 bytes 
  System.Web.dll!System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext context, System.AsyncCallback cb, object extraData) + 0x91 bytes 
  System.Web.dll!System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest wr = {System.Web.Hosting.ISAPIWorkerRequestOutOfProc}) + 0x194 bytes 
  System.Web.dll!System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest wr) + 0x62 bytes 
  System.Web.dll!System.Web.Hosting.ISAPIRuntime.ProcessRequest(System.IntPtr ecb, int iWRType) + 0x57 bytes 
  [Appdomain Transition] 
  [Native to Managed Transition] 

When navigating away from that page, session_start is fired and with the following call stack:

ConciergeDesk.Site.Shop.DLL!ConciergeDesk.Site.Shop.Global.Session_Start(object sender = {System.Web.SessionState.SessionStateModule}, System.EventArgs e = {System.EventArgs}) Line 27 C#
  System.Web.dll!System.Web.SessionState.SessionStateModule.RaiseOnStart(System.EventArgs e) + 0x8c bytes 
  System.Web.dll!System.Web.SessionState.SessionStateModule.CompleteAcquireState() + 0x9b bytes 
  System.Web.dll!System.Web.SessionState.SessionStateModule.BeginAcquireState(object source, System.EventArgs e, System.AsyncCallback cb, object extraData) + 0x21f bytes 
  System.Web.dll!System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() + 0x5b bytes 
  System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step = {System.Web.HttpApplication.AsyncEventExecutionStep}, ref bool completedSynchronously = true) + 0x9c bytes 
  System.Web.dll!System.Web.HttpApplication.ResumeSteps(System.Exception error) + 0x163 bytes 
  System.Web.dll!System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext context, System.AsyncCallback cb, object extraData) + 0x91 bytes 
  System.Web.dll!System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest wr = {System.Web.Hosting.ISAPIWorkerRequestOutOfProc}) + 0x194 bytes 
  System.Web.dll!System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest wr) + 0x62 bytes 
  System.Web.dll!System.Web.Hosting.ISAPIRuntime.ProcessRequest(System.IntPtr ecb, int iWRType) + 0x57 bytes 
  [Appdomain Transition] 
  [Native to Managed Transition] 

What does the [Appdomain Transition] mean? Is this normal for a standard navigation?

 

0
Egdif
1/12/2007 11:03:06 PM

For anyone who's interested the cause was due to setting EnableSessionState to false. The pages that were triggering session_start when navigating away from them all had this set in the @page declaration.

I was under the impression that session state was still preserved with this setting, just that you couldn't modify it, only read it.

Ben

0
Egdif
1/13/2007 1:29:24 PM
Reply:

Similar Artilces:

Session variables are lost with every request even though session persists
Hi, I am new to .NET and this is my first application with session state management. I am using .NETs login controls and database for login/password security management. I have a folder called "secure" which requires the user to login. The login page itself is out site this folder. Once a correct a correct login/password are provided I store the UserID in session and redirect to next page inside "secure" folder.The problem is that session["userID"] is null on the next page even though Context.Session is not. I tried to add UserID in session again on a page inside "secure" folder but that to...

The page requires session state that is no longer available. Either the session has expired, the client did not send a valid session cookie, or the session state history size is too small. Try increas
Hi.. I am making a mobile application using .net framework 2.0. My Application has  web farm scenario so for state management  I am using Sateserver in my application. My application runs fine if I dont use web farm scenario But in case of web farm scenario it is giving me error "The page requires session state that is no longer available. Either the session has expired, the client did not send a valid session cookie, or the session state history size is too small. Try increasing the history size or session expiry limit."   &...

"The page requires session state that is no longer available. Either the session has expired, the client did not send a valid session cookie, or the session state history size is too small. Try increa
Hi.. I am making a mobile application using .net framework 2.0. My Application has web farm scenario so for state management I am using Sateserver in my application. My application runs fine if I dont use web farm scenario But in case of web farm scenario it is giving me error "The page requires session state that is no longer available. Either the session has expired, the client did not send a valid session cookie, or the session state history size is too small. Try increasing the history size or session expiry limit." I am not getting why this error is coming ..Though I already h...

Unable to make the session state request to the session state server
Hi all, I'm working on the website http://universityauction.net and I was using session variables using InProc session mode to manage session state. This worked fine until I put the website in a load balanced environment, as inproc sessions get lost when jumping from server to server. I decided to move to a state server mode, so I changed my web.config to: <sessionState             mode="StateServer"             stateConnectionString="tcpip=123.456.7.8:42424"      ...

Unable to make the session state request to the session state server.
 Hello,           I’m receiving this error when I put my website on production."Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.  If the server is on the local machine, and if the before men...

Session variables lost after a redirect page
Hi all , I have encounter a session variable lost after a redirect page when i set the cookiesless=false in web.config. This happen when u i tried to access the asp.net application from another pc while my asp.net application reside in another web server. therefore in order to solve this problem i tried to change in the web.config file by setting the cookieless =true than it works. <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="true" timeout="20"/> how can i have this prob...

Unable to make the session state request to the session state server #2
We have recently started receiving these errors in the event viewer. We are using the out of proc state server on the same machine. The errors become more frequent, almost like it snowballs until users cannot work. System Info: Windows Server 2003 Standard SP2 , 4 GB of RAM, IIS 6.0, Asp.Net 2.0. What I know for certain: The state server is started and running Recycling the app pool nor restarting IIS fixes the problem Rebooting the machine DOES temporarily fix the problem. I changed the stateNetworkTimeout from 10 to 20 in webconfig and that had no effect. There is usuall...

Unable to make the session state request to the session state server etc.
We are getting an error message "Unable to make the session state request to the session state server..." sporadically in one of our applications.  We have several applications running on a 4-server web farm, and these applications have been in production for a year, so it is not a problem that the server is not reachable, not started, not addressed correctly, etc etc etc. One of the applications *does* put a lot of large datasets into session state.  Is there a limit on the allowable size of a session/cached object?  Also, the application opens several windows at once, ...

Error: Unable to make the session state request to the session state server
I have session configured in web.config this way:<sessionState mode="StateServer" cookieless="true", timeout="30" stateConnectionString="tcpip=127.0.0.1:42424" />  ASP.NET State Service is started.   I got an error:  Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentContr...

Unable to make the session state request to the session state server
 We have a web application in our school called CHECM. We are experiencing a high volume of ASP.NET State Server errors throughout this month. These errors have been occurring since 7/11/2006.   Our Session State Mode has been --------------------------------------------------------- <sessionState mode="StateServer" stateConnectionString="tcpip=CHECM:42424" timeout="20" stateNetworkTimeout="30"/>     Here is the Error we get randomly Exception: System.Web.HttpException Message: Unable to make the session state request to the session state server. P...

State management upon session variable changes
I noticed that whenever a session variable is changed...the application knows about it and suddenly restarts session. My question is does restart "ALL" sessions or only the active sessions for which the variables changed? Imagine a "multi-user" application all with different states and an administration panel that lets you change session variables.  In this case, my question has to do with the question that if Company X changes his session variables, will only Company X's sessions be reset or will all "sessions" be reset?  Hope that makes sense. ...

Visual Studio 2005
 Hi, I have recently been given a PC with Vista on it, and installed Visual Studio 2005 pro. I then moved a ASP.net web project from an XP machine to the Vista one. When I run the project from inside Visual Studio (debug mode) everything works fine on the front end of the website, but if I try and log in I get the following error:  Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that i...

Error message
Hello,I have developed an ASP.NET c# application.I have a "Reports" page in which i put the the report's DataTable in a session (to use it later on for paging and sorting).This works on my localhost but on production I get the follwong error:Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic...

access session state variables from non-page class
is it possible to access session state variables from a non-page class? my login page initializes the session variables. on another page, some session variables are used to keep track of user dictated filter parameters.  the user can click reset filters which requires the session variables to be reset.  it'd be nice to put a method of initializing session variables in 1 place, such as a non-page class i call SharedMethods. i realize session variables do not need to be initialized.  however, trying this approach led me to embed string x = Session["sessionX"] ...

Web resources about - Session variables lost between page requests - asp.net.state-management

Variable - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Westpac interest rate rise is one of many variable loan rate rises
WESTPAC is not alone in hitting its owner-occupier customers with a surprise interest rate rise, as dozens of other variable rate home loans ...

Airbnb upgrades variable pricing tool for hosts
Online home rental group Airbnb is rolling out an upgraded variable pricing tool that automatically raises or cuts room rates based on supply ...

Commonwealth Bank raises variable home loan rates
Home owners' mortgage costs are set to rise by hundreds of dollars a year, after the Commonwealth Bank became the latest bank to hike interest ...

CBA lifts variable home loan rates to offset costs associated with stricter capital requirements
The Commonwealth Bank to lift its home loan interest rates independently of the Reserve Bank to partially offset costs associated with stricter ...

Washington Square Signs Spielbergs, Choi Joins Variable and More
... films and an episode of the HBO comedy series "Girls," on which he plays the role of Ray Ploshansky. New York-based creative collective Variable ...

YouTube v10.32 Tweaks Some Interface Elements And Includes Hints About Virtual Reality Content And Variable ...
Forget Update Wednesday! Monday is the new big day. Not only were we treated to the latest M preview release and the official Marshmallow name, ...

"You have to ignore many variables to think women are paid less than men. California is happy to try." ...
Writes Sarah Ketterer in The Wall Street Journal in "The ‘Wage Gap’ Myth That Won’t Die" (which you can get to without subscribing if you Google ...

Cisco Debuts Open Pay Variable Pricing, Updates CCRE
Cisco Debuts Open Pay Variable Pricing, Updates CCRE Channel Partners Kris Snow, president of Cisco Capital, says the company's new Open Pay ...

Expert Reveals the Latest Variable Capacity Technology
Learn about gForce Ultra CRAC equipment, the latest variable capacity technology to lower energy usage and increase reliability.

Resources last updated: 12/5/2015 4:42:35 PM