Troubleshooting Session Related Issues in ASP.NET
page 2 of 7
by Rahul Soni
Feedback
Average Rating: 
Views (Total / Last 10 Days): 61804/ 83

Questioning

Question 1: When you say it is a Session Loss, what actually happens? Does the person browsing the website get logged out all of a sudden and he gets re-directed to the Login page (OR is it something specific he does which logs him out)?

Answer 1: Varies, since it is an open ended question.

Inference> At this point, it could be a session timeout issue or a session loss or anything else for that matter! The only thing which is certain is that we need to ask a lot of other questions and narrow the issue down to something which we could fix.

In comes Question 2: Is the issue random? Can you reproduce it at will?

Answer 2: Let us say the answer is YES, it is Random (this is the case mostly). I would jump to Question 3. If it is reproducible, I become quite happy and jump to Question 4. Basically, if the issue is reproducible, you will have quite a few ways in which you can fix it which is good. The unfortunate part is that you might have to go with trial and error, which could be painful.

Inference> Without even doing anything, we now have a few areas to look at depending on whether the issue is reproducible or not. Have a look at the next questions.

Question 3: At this point we know that the issue happens randomly. So, I am now keen to find out if all the users get logged out at the same time, it is problem with just some client(s) OR all the users faces this problem randomly.

Answer 3: To me it is one of the most important questions. I will tell you why.

Let us say he says “Yes,” all the users get logged out sporadically at the same time.
Inference> That would mean that there are two possibilities now at a broader level. The Application Domain is getting recycled for some reason OR the worker process (aspnet_wp.exe > in XP or 2000 box OR w3wp.exe > in 2003 box) is crashing.

The question now is… how you will find it out if it is…

AppDomain restart?

You can add a Perfmon counter and monitor your server as follows…

Click Windows Start button -> Run. Type Perfmon and click Ok.

Expand Performance Logs and Alerts.

Right click Counter Logs and select New Log settings.

Type a name and click Ok.

Click on Add Counters button.

From the Performance object select ASP.NET v.1.1.4322 or the ASP.NET version of your application.

Choose Select counters from list and select Application Restarts.

Click Add, Close, and Ok.

You will notice that the Perfmon will start logging data into this log file.

Once the issue happens (I mean all the users get logged out), right click on your Counter Log file and click Stop.

If you right click and choose properties, it will show you the path where the log file is stored. By default, it is C:\Perflogs, but you can change it.

Notice the path, go to System Monitor in the left pane and click View Log Data in the right pane.

Add the Log file using Add button and click Ok.

Click on Add Counter (+) button, select Application Restarts counter and click on the Add button. Click Close.

Basically, we are checking if the ASP.NET applications are starting for any reason. If it is doing so, you will see a value > 0 and your graph might look like a single (or multiple) step (s) in a staircase.

Figure 1


I have reproduced the Application Restart by touching web.config of my Application a few times. Notice the graph has steps. Also, notice that I have changed the Graph of Perfmon to 10 and the scale for the Counter is set to 1,000 so that the graphical representation makes more sense
 
If you see this, it means that your ASP.NET application is restarting because of a web.config change, a machine.config change, global.asax change, your application’s bin folder change or multiple changes in your aspx files. If that is the case, check the following scenarios.


View Entire Article

User Comments

Title: Need some urgent help   
Name: Paks
Date: 2012-04-25 8:22:34 AM
Comment:
Hi,

Your article is wonderful. Very useful. But with my issue I still don't have resolution. It would be good if you can through some light on it.

We use:
ASP.NET 6.0, State Server to store sessions and IIS 6.0.
A single server as - web as well as state server. No farm nothing.

Issue is we physically moved the severs to a new data center. Suddenly we have started observing session data getting lost. Behaviour is random and not getting replicated on any of the dev servers. Also many a times only part of the session data is lost and not all the values. It's strange. I do not want to enable application level trace on production as well performance monitor tool does not seem to be helping in my case.
Can you help out with the issue. Suggest some external tool which monitors the issue or is it possible to write small .NET app to trace the existing web app.
Your suggestions are valuable.

Thank you.
HV
Title: need help   
Name: sivarj
Date: 2010-06-10 2:11:04 AM
Comment:
I am uisng farpoint grid,while pageloading farpoint grid overlapping first row with header how to over come this problem
Title: Thanks Bro   
Name: Vishal Jani
Date: 2010-01-04 8:05:17 AM
Comment:
Hi,

After long googleing I find your article and thanks for
your observation. It saves my project.
Just only after creating upload directory outside the application direcotry my session loss problem has been solve.

Thanks again.

Regards,
Vishal Jani
Title: Thank you   
Name: Payal
Date: 2008-12-02 2:46:45 AM
Comment:
thanks a lot..its exactly what i am looking for..
Title: Session Conflict (For Payal)   
Name: Rahul Soni
Date: 2008-12-02 1:47:35 AM
Comment:
Hi Payal,

If you are seeing shared sessions, the first thing that you should check is Caching. See if you have Caching enabled and proceed form there.

http://blogs.msdn.com/jorman/archive/2005/11/22/495753.aspx

HTH,
Rahul
Title: Session conflict   
Name: payal
Date: 2008-12-02 12:39:36 AM
Comment:
Hi Rahul,

This is article gives me a lot of insight for using session or resolving session related issue. But i am facing some major problem with session state in asp.net 1.1 application.

Session variables are conflicting with each other that means if there are two/three simultanous user using the web application at same time, some times they can view the details of other users and vice-versa. When i debug the application i hv not found any issues. I am just storing employee ID which is numeric. Can you please help me to resolve this issue?

thanks
Payal
Title: Web Farm - Complex object storing issues   
Name: Rahul Soni
Date: 2008-10-21 6:37:02 AM
Comment:
Hi Senthil,

Server.Transfer is executed at the server side, which means that the code would execute on the server which is catering to the request. Response.Redirect might end up on a new server, but Server.Transfer wouldn't.

Regarding the 2nd query, you need to ensure that the objects are serializable, else you would see an error message while trying to store that objects in the session.

But honestly, try NOT to store very large objects, specially you should always ensure that whatever you are storing in session is short and sweet. Large session objects (> 85K) would end up in LOH and hence complicate your App's memory requirements.

HTH,
Rahul
Title: Web Farm - Complex object storing issues   
Name: Senthil Valavan & Meyyapan
Date: 2008-10-21 5:48:59 AM
Comment:
Hey Rahul,
Ur Comments were nice ,

Please help up in this following scenerio for WEB FRAM


1) When using Server.Transfer in our application , will it make any issues on WEB Farm

2) While Storing Complex Objects (Like hashTable & Class objects ) into Session (SessionState=SqlServer). Could you brefiely explain any specific steps need to be taken.
Title: Is it complete...   
Name: Deep
Date: 2008-09-11 6:31:49 AM
Comment:
Rahul,

Article looks great, our problem is here:

"Notice… it is not a problem which “All the users face at the same time.” It is something which is happening to ALL the users, BUT NOT AT THE SAME TIME."

But it seems the article is not giving tips for this scenario or I missed sth.

Your advice will be helpful.

Regards,
Deep
Title: Web garden...doh!   
Name: Aaron
Date: 2008-05-15 12:22:25 PM
Comment:
I got caught by setting the application pools to use two processes (web garden area) and not setting out of process sessions. Thanks for this article it just saved me a lot of trouble.
Title: For Mihir   
Name: R S
Date: 2007-08-22 12:20:46 PM
Comment:
Hi Mihir,

In fact, ASP.NET and ASP.NET Applications are not generic, and they are supposed to show the Perfmon as per your observation. That is, it will show the counters for the latest version of .NET Framework installed on your box.

If you have 1.1 and 2.0 both, it won't show any 1.1 counters. If you need to see 1.1 counters, you will need to add them explicitly.

Hope that helps,
Rahul
Title: Asp.Net and Asp.Net Applications are generic ?   
Name: Mihir
Date: 2007-08-22 11:26:21 AM
Comment:
Hey Rahul,
Nice two see this article.
I have some concern here..any internal article will help.
I'm using PERFMON utility to measure performance of an asp.net application with Asp.Net and Asp.Net Applications performance objects (attribute group) of PERFMON Utility. I've deployed 2 same Asp.Net application on my machine, the only difference is one is developed using Asp.Net 1.1 and the other is developed using Asp.Net 2.0. Through observation I've noticed one thing that's Asp.Net and Asp.Net Application attribute group reflects the values same as Asp.Net 2.0. and Asp.Net Apps 2.0 attribute group and not refecting the values those are of Asp.Net 1.1.4322 and Asp.Net Apps 1.1.4322 attribute groups.

My understanding for this is Asp.Net and Asp.Net Applications are generic attribute group(Performance Objects) and they should refelect values of both attribute groups (Asp.Net 1.1.4322 and Asp.Net 2.0 as well Asp.net Apps 1.1.4322 and Asp.Net Apps 2.0). I've all 3 versions of .Net installed on my machine but I'm not getting any attribute group specific to Asp.Net 3.0 like previous two.

Can anyone make me clear on which attribute group to use for measuring performance of various Asp.Net Application i.e. Generic one or Version Specific? Because the Perfmon utility shows both generic i.e ASP.NET
and version specific performance objects like (ASP.NET v1.1.4322)

I am stuck please help.
Title: Thank you   
Name: Narayanan
Date: 2007-07-04 1:47:44 AM
Comment:
Excellent article
Title: A little more information!   
Name: Rahul Soni
Date: 2007-03-30 11:47:06 AM
Comment:
I guess, I missed this very important KB article
http://support.microsoft.com/?id=184574. It talks about certain cases where you will have multiple ASPSessionID cookies. As you know a lot of cookies might hurt the performance, and it could also lead to Session Loss.

Just thought I should addding this information here!

Cheers,
Rahul Soni
Title: Simple and Useful   
Name: Ravi Garg
Date: 2007-03-29 12:51:56 AM
Comment:
Well thats great!
An article when solving a security issue must be as simple as it could be.
Title: Great Article   
Name: Parag Agarwal (paraga)
Date: 2007-03-17 2:01:20 PM
Comment:
I came across this article .. good work keep going..
Title: Troubleshooting Session Related Issues in ASP.NET   
Name: Saurabh
Date: 2007-03-07 2:46:01 PM
Comment:
Excellent stuff....This is really helpful for people who are struggling with issues related to Session loss in As/Asp.net Web applications.

-Saurabh

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-26 8:22:35 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search