Lately, I encountered an issue where IIS was keep crashing every minute due to unhandled exceptions. There was nothing much in application logs except event viewer, which says application pool “xyz” terminated unexpectedly.

This was happening in IIS 6 with .Net 4.

Are you experiencing similar issue?

The reason IIS keep crashing caused by unhandled exception is because the default policy for a unhandled exception has changed in the .Net framework 2.0 and later version. The behavior for this policy is to end the worker process.

Possible fixes

To fix this permanently, a developer must handle all exceptions in the application.

As a workaround, you can change unhandled exception policy back to legacy (.Net framework 1.x)   

  • Login into problematic IIS server
  • Find which version of .Net you are using
  • Go to below folder
%WINDIR%Microsoft.NETFramework$.Net_Version
  • Take a backup of Aspnet.config file
  • Modify or add if doesn’t exist following
<configuration>
<runtime>         
<legacyUnhandledExceptionPolicy enabled="true" />     
</runtime> 
</configuration>
  • Restart IIS Application pool

You will notice, IIS will prevent crashing and you are back in business.

Reader Interactions

Comments

  1. Nice blog here! Also your website loads up
    very fast! What host are you using? Can I get your affiliate
    link to your host? I wish my website loaded up as fast
    as yours lol

Comments

Your email address will not be published. Required fields are marked *