Our Situation:
We have several webservers behind a loabalancer (Astaro Security Gateway). On the webservers we run an asp.net application and we have customerrorpages configured for 404 and 500 status codes.
Now when the Application fails to start every request is redirected to the errorpage by sending status code 302 and the errorpage itself then sends a 500.
The loadbalancer sends a HEAD request to our webservers every 15 seconds to see if its still alive and if so it checks the first html status code. So it only sees the 302. Every code below 500 is treated as server is up and running.
Question:
How can we make our loadbalancing work if the application failed to start?
Edit:
By Application failed to start I mean that during the startup there were errors. Some essential parts could not be initialilzed and therefore every page fails to execute.
A couple of ways:
In your web.config on the customErrors mode set the
redirectModetoResponseRewrite– this removes the 302 redirect from the server to the error page – this also has the happy coincidence that uses can easily see what the original page they requested was, and can retry with an F5 if that’s likely to resolve the issue.If you are hooking into the ApplicationError event, make sure that rather than redirecting to your error pages you use
Server.Transferinstead.I have the following in one of my web.configs:
Then in my ErrorHandler page I check for the last error from the server, and configure those:
Obviously you may want to do additional processing – for example before I do all this I’m comparing the original request with my Redirects database to check for moved content/vanity urls, and only falling back to this if I couldn’t find a suitable redirect.