HandleErrorAttribute and Remote Connections

Last week I upgraded my main application to MVC Preview 4. This morning I noticed that a number of users were receiving HTTP 500 error messages instead of being presented with a friendly error page.

It turns out the HandleErrorAttribute in Preview 4 is the culprit. Previously I'd been using MvcContrib's RescueAttribute.

It appears that the HandleError attribute only works locally - when using a remote connection the server just displays the standard HTTP 500 message (this is under IIS7 using Integrated Pipeline).

I fired up the MVC source code and removed this line from HandleErrorAttribute.cs (line 85):

filterContext.HttpContext.Response.StatusCode = 500;

After doing this, the error pages are displayed correctly.