IIS Home @ it-notebook.org

Application state lost; Error 500 when ASP file is missing

(Kristofer Gafvert, September 16, 2007)


Each week I take two questions from the IIS newsgroups (or IIS forums) that I think is of public interest, and I answer them here as well. Questions and answers may be modified to be more general and more useful for everyone.

Application state lost

I have a web application that is deployed on Windows Server 2003 Web Edition. We are using .NET 2.0 and the application works flawless on this server. But on another server, running Windows Server 2003 Enterprise Edition, it crashes and we have traced it down to be caused by loss of application state. Why does application state get lost and why does it work on one server and not the other?

Why it works on one server and not another is most likely because of a setting that is not the same on both servers. IIS is not significant different between Windows Server 2003 Web Edition and Windows Server 2003 Enterprise Edition, so whatever web application that runs on either one of them, should run on the other.

Application state is stored in memory on the server and is faster than storing (and retrieving) information in a database, which is a great advantage. This is however also the disadvantage of application state (that it is stored in memory). All data stored in memory has a "feature" in common, it is "owned" by a process and may not be accessed by other processes and vanishes when its process is closed down.

So whenever the application is stopped or restarted, application state is lost. This includes the following situations:

  • Web.config file is changed
  • The application pool is restarted due to the settings on the application pool
  • The application pool is restarted due to a failure

Furthermore, application state is not shared among multiple worker processes serving the same application pool. So if you have a Web garden, the application state may seem "lost" (it is not actually lost, it is just not the same for all worker processes serving the application pool).

"500 Internal Error" returned instead of "404 File not found" when ASP files is missing

I am running IIS 6.0, and whenever a client tries to access an ASP file that does not exist, they get a "500 Internal Error" instead of the usual 404. This is happening on ASP files only, not .html, .aspx, .php or any other extension.

When IIS gets a request for a non-existing file, it can do two things:

  1. Return a 404 status code
  2. Route the request to an ISAPI filter/extension

What it does depends on your settings. When you set up an application mapping for the asp extension, you have the option to set "Verify that file exists". If this is unchecked, IIS will route the request to the ISAPI extension responsible for the asp extension. The ISAPI extension will then be responsible to handle the missing file accordingly. The ASP extension does not do this by default.

So the most likely cause for this status code to be returned instead of the 404 status code is that you have disabled "Verify that file exists" (it is enabled by default for the ASP extension). To change this, follow these steps:

  • Right click the website (or the server name, depending on which level you want to configure this on) in IIS Manager and click Properties.
  • Click on the Home Directory tab and then the Configurations button.
  • Select the .asp extension and click the Edit button.
  • Enable "Verify that file exists".
Verify that file exists in IIS Manager

Applies to [?]

IIS 6.0


ASP.NET Application State Overview
HOWTO: Understand and Diagnose an Application Pool Crash