I have created custom views for an MVC app.
I let the errors bubble up to the Application_Error handler in my Globals.asax file and perform a redirect to an error controller which renders those views:
protected void Application_Error(object sender, EventArgs eventArgs)
{
    Exception exception = Server.GetLastError();
    Response.Clear();
    var httpException = exception as HttpException;
    Response.TrySkipIisCustomErrors = true;
    if (httpException != null)
    {
        switch (httpException.GetHttpCode())
        {
            case 404:
                Server.ClearError();
                Response.Redirect(UiConstants.PageNotFoundPage);
                break;
            case 500:
                if (httpException.Message.Equals(UiConstants.NoSessionStateExceptionMsg, StringComparison.Ordinal))
                {
                    Server.ClearError();
                    Response.Redirect(UiConstants.SessionNotAvailablePage);
                }
                else
                {
                    Server.ClearError();
                    Response.Redirect(UiConstants.ServerErrorPage);
                }
                break;
            default:
                Server.ClearError();
                Response.Redirect(UiConstants.ServerErrorPage);
                break;
        }
    }
    else
    {
        Server.ClearError();
        Response.Redirect(UiConstants.ServerErrorPage);
    }
}
In my development environment (VS Dev Web Server), this works as designed. When I deploy this to a test server, the stock IIS error web pages display, instead of my views.
The route path is correct i.e. servername/StaticContent/PageNotFound
Any ideas how to resolve this? Is there some IIS setting doing this?