Hiding that "Server Application Unavailable" error message - Answered
Time's up, pencils down.
Almost a year ago, I asked if anyone had figured out how to hide that awful Server Application Unavailable message:
Server Application Unavailable The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request. Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur. |
That message overrides whatever pretty custom 404 / 500 error pages you may have defined in IIS and / or your ASP.NET web.config, since it occurs after the page request has been passed from IIS to the ASP.NET ISAPI filter, but ASP.NET isn't able to process the request.
I figured it out - like a lot of things, it's built into ASP.NET, but it's not easy to find unless you know where to look.
The machine.config <processModel> node has a serverErrorMessageFile attribute, which can point to an HTML page. HTML is the safe bet here rather than trying any kind of server processing, since the fact that the Server Error Message is showing means you probably can't process requests.
An easy way to test your custom error message page is to edit your machine.config and temporarily change the processModel/password to "DoNotAutoGenerate". After you've tested, change it back to "AutoGenerate".
You can override the <processModel> in your application's web.config file, but I recommend also setting the custom error message in the machine.config, since a severe server error may mean that your web application can't be started, the web.config file can't be read, etc.