I'm trying to get the custom 404 page we've built to display instead of the default 404 page created by the server. It works as intended when debugging the application locally, but not when running the application on the server. And their web.config files look exactly the same.
<customErrors mode="On" defaultRedirect="~/Error/Index">
<error statusCode="404" redirect="~/Error/NotFound" />
</customErrors>
The weird thing is when anything about the is modified - setting mode to "Off" or "RemoteOnly", changing "~/Error" to just "Error", or removing the section entirely - the result is always the same: I get my nice looking 404 page locally, but not on the server.
When debugging locally, this method executes as intended:
public class ErrorController : BaseController
{
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult NotFound()
{
Response.StatusCode = (int)HttpStatusCode.NotFound;
ErrorSignal.FromCurrentContext().Raise(new HttpException(404, Request.Url.PathAndQuery + " was not found"));
return View();
}
}
Because it found this route in Global.asax:
routes.MapRoute(
"NotFound",
"{*path}",
new { controller = "Error", action = "NotFound" });
Any and all advice is appreciated.