views:

80

answers:

4

Our ASP.NET 2 web application handles exceptions very elegantly. We catch exceptions in Global ASAX in Application_Error. From there we log the exception and we show a friendly message to the user.

However, this morning we deployed the latest version of our site. It ran ok for half an hour, but then the App Pool crashed. The site did not come back up until we restored the previous release.

How can I make the app pool crash and skip the normal exception handler? I'm trying to replicate this problem, but with no luck so far.


Update: we found the solution. One of our pages was screenscraping another page. But the URL was configured incorrectly and the page ended up screenscraping itself infinitely, thus causing a stack overflow exception.

A: 

You could try throwing a ThreadAbortException.

David M
+1  A: 

In order to do this, all you need to do is throw any exception (without handling it of course) from outside the context of a request.

For instance, some exception raised on another thread should do it:

protected void Page_Load(object sender, EventArgs e)
{
   // Create a thread to throw an exception
   var thread = new Thread(() => { throw new ArgumentException(); });

   // Start the thread to throw the exception
   thread.Start();

   // Wait a short while to give the thread time to start and throw
   Thread.Sleep(50);
}

More information can be found here in the MS Knowledge Base

Rob Levine
+2  A: 

The most common error that I have see and "pool crash" is the loop call.

public string sMyText
{
   get {return sMyText;}
   set {sMyText = value;}
} 

Just call the sMyText...

Aristos
+2  A: 

Aristos' answer is good. I've also seen it done with a stupid override in the Page life cycle too when someone change the overriden method from OnInit to OnLoad without changing the base call so it recursed round in cirlces through the life cycle: i.e.

protected override void OnLoad(EventArgs e)
{
  //some other most likely rubbish code
  base.OnInit(e);
}
BritishDeveloper
ah, yes this is also something that I have see... +1
Aristos