Welcome!

Performance, Scalability and Architecture

Andreas Grabner

Subscribe to Andreas Grabner: eMailAlertsEmail Alerts
Get Andreas Grabner via: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Related Topics: Azure Cloud on Ulitzer, Microsoft Developer

Blog Feed Post

Why Do I Lose My ASP.NET Sessions Due to Constant AppDomain’s Recyclings?

Migrated an Application from .NET 1.1 to .NET 2.0

Microsoft Developer on Ulitzer

This might be an “old hat” for most of you experienced ASP.NET Developers out there – but I think it is worth another blog entry as I just ran into the following problem:

Step 1: Migrated an Application from .NET 1.1 to .NET 2.0

I worked with an ASP.NET Application originally developed on ASP.NET 1.1. We upgraded to . NET 2.0 using Visual Studio 2008 and the project conversion wizard. Besides some problems with the conversation of project files and web service proxies – that could all be fixed manually – the conversion went smoothly. The application could be started without any problems and seemed to work fine – at least as long as we did not modify the data in the file based data store. All these transactions seemed to cause the loss of all our current ASP.NET Sessions.

Step 2: Debugging through the code

A debugging session showed us that the reason for the lost ASP.NET Sessions was an unexpected recycling of the AppDomain which led to the loss of any currently active sessions. Unfortunately we couldn’t see any reasons why the AppDomain was restarted. There were no severe exceptions nor did anybody change the web.config file on the fly (which would cause a restart).

Step 3: Reading blog entries about AppDomain Recycling

There are a number of blog entries that describe why AppDomain’s might get recycled. And some of them explained a change that happened from .NET 1.1 to .NET 2.0:

Step 4: Identifying our problem

So it turned out that due to the File Change Notifications on the WebRoot directory and all subdirectories AppDomains will now be recycled in case any file in this directory or subdirectory is changed/added/removed. In .NET 1.1 this was not the case – only certain files were checked for modification, e.g.: web.config.

The ASP.NET Application on our hands used a single file based database that was stored in the bin directory of our ASP.NET Application. When changes were commited to the DB and the ADO.NET driver committed those changes to the file system the File Change Notification triggered an AppDomain restart and we lost all of our current ASP.NET Sessions.

Conclusion

Be aware of this change in AppDomain recycling when migrating an older ASP.NET 1.1 Application to ASP.NET 2.0

Related posts:

  1. ASP.NET MVC: Hidden Performance Problem with HtmlHelper.RenderPartial functions The problem that has been discovered in this blog entry...

Read the original blog entry...

More Stories By Andreas Grabner

Andreas Grabner has been helping companies improve their application performance for 15+ years. He is a regular contributor within Web Performance and DevOps communities and a prolific speaker at user groups and conferences around the world. Reach him at @grabnerandi