Monday, March 20, 2006

A lot of IIS restarts. Strange behavior!

Suddenly, one app goes slowly...

Watching the IIS log of one of our application, all I can found was a lot of IIS restarts. Digging into the IIS configurations, app code and all I can suppose I can't found any result.

Then I try to test the app in debug mode, and all I can find was a error like this:
"An unhandled exception of type 'System.Threading.ThreadAbortException' occurred in Unknown Module.

Additional information: Subproceso anulado.
"

Well... the IIS restarts any time I wrote into the MS Access database. Perhaps a problem with the ODBC?... No

Resolution:
The problem was that someone had taken the decision to put the database into the bin directory for avoiding web downloads of it and ensuring IIS read/write permissions. Bad Idea!!!. Why? Because IIS has a file watcher to the bin and its subdirectories, and when one file into them changes IIS recycles the appDomain.

How can you avoid web downloads of some of your files?

1. Open the Web.config file in a text editor such as Notepad. The Web.config file is located in the root directory of your Web application.

2. In the Web.config file add the configuration element under the element.
Note You must not copy the element from the Machine.config file. The reason you must not copy the element is because the element permits you to add additional file types without completely overriding the Machine.config settings.

3. In the element, use sub tags to specify additional file types that you want blocked. Set the verb attribute equal to “*”. When you do this, you specify that all types of HTTP requests are blocked. Define the path attribute as a wildcard character that matches the types of files you want to block. For example, you may specify “*.mdb”. Finally, set the type attribute to “System.Web.HttpForbiddenHandler". The code sample that follows shows how to configure the "httpHandlers" section in the Web.config file.


<system.web>
  <httphandlers>
    <add type="System.Web.HttpForbiddenHandler" path="*.mdb" verb="*" />
    <add type="System.Web.HttpForbiddenHandler" path="*.csv" verb="*" />
  </httphandlers>
</system.web>


4. Save the Web.config file. The ASP.NET application automatically restarts.


Permalink: A lot of IIS restarts. Strange behavior!