Reputation: 799
My asp.net application gives an exception once in a while as a result application pool stopped. and it needs to be started manually.
Does anyone know how to trace it, how to find what cause the problem?
I don't see any errors in Event Viewer.
Upvotes: 0
Views: 258
Reputation: 1786
Are you absolutely certain your application pool is stopping due to an error? There are many reasons the application pool can stop. Unless configured otherwise by default it will stop if inactive after a set ammount of time. I think about 20 minutes.
Upvotes: 0
Reputation: 4012
Try putting an Application_Error method on Global.asax.cs like this:
protected void Application_Error(object sender, EventArgs e)
{
// Get the exception object.
Exception exception = Server.GetLastError();
_Log.Error(exception.Message, exception);
// Clear the error from the server
Server.ClearError();
}
The _Log line assumes you're using log4net or some other logging framework but you could do whatever you want with the error.
PS - There's some misinformation in some of the other comments. But I don't have enough rep to comment on them. All IIS / WCF web service apps that I've written will terminate if any thread has an unhandled exception. I can't speak to whether that's true of ASP.Net apps as well.
Upvotes: 0
Reputation: 300489
In IIS 7.0, events (configurable) and exceptions (always) are logged to the Windows event log when an application pool recycles.
Sccot Guthrie's round-up of Tess's related posts is great:
Upvotes: 3