开发者

My application giving an exception once in a while

My asp.net application gives an exception once in开发者_StackOverflow中文版 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.


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:

  • Outstanding Blog for Learning how to Debug ASP.NET App Issues (Memory Leaks, Crashes, Deadlocks, etc)

  • ASP.NET 2.0 Crash case study: Unhandled exceptions


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜