开发者

Why would IIS "start" an App that is still running?

We have an ASP.NET (3.5 SP1) application running on IIS7 / Windows 2008. We trap Application_Start and Application_End events in Global.asax. We also host WCF services in the app and trap the OnOpening and OnClosing events via a ServiceHostFactory. Thus, we thought, we are guaranteed notification of any application start and stop, scheduled or unscheduled.

Several days ago our application caught an Application_Start event while in a 'started' / 'running' state.

No Application_End event preceeded the Application_Start (or even followed it a few minutes later, if race conditions are considered).

Our first thought was that our application actually silently crashed and terminated. Actually what happened w开发者_StackOverflowas a new App Domain spun up to service inbound requests but the existing App Domain's background threads (we do lot's of stuff in ThreadPool threads) remained running for several days -- until I killed them with an IISRESET.

The guess is Application_End did not fire because the original AppDomain did not end... but then why did Application_Start fire?

Looking for a tip or document describing how this semi-shutdown+AppDomainStartup mechanism works in ASP.NET.

Thanks in advance,

Howard Hoffman


Please learn about application pool recycle, which can lead to such situations. When IIS determines to recycle a pool, it simply initializes a new worker process first (Application_Start will be called in turn), and then shuts down the old (Application_End).

I suggest you add some application level logging with process id in logs, to better understand if my above analysis is right.

For ASP.NET developers, learning more about IIS is recommended.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜