Sunday, October 14, 2012

Web App Restarting Unexpectedly


What happened?


This was an ASP.NET application. It used forms authentication. The user logs in, navigates to a number of pages here and there and suddenly upon hitting few particular pages, the web app would restart. I knew this because 1) the user lost session 2) logs that are typically collected at Application_Start.

This was rather a puzzling and mysterious behavior of an app that's worked with no such issue for many months.

The Cause:


There was a piece of code in those few pages that wrote to a config file (a file whose extension is .config but not web.config). This was IIS6. This change to this config file triggered the AppPool to recycle and thus the application to restart.

The fix is obviously simple: don't write to the config file.