I'm getting a couple of errors when trying to use custom 404 and 500 error pages in MVC 2. I'm essentially trying to implement what I've found here: http://www.genericerror.com/blog/2009/01/27/ASPNetMVCCustomErrorPages.aspx So far, I have:
Placed the following line in my Web.config:
<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/Error/Http500" />
Placed the following route last in my route table:
routes.MapRoute(
null,
"{*path}",
new { controller = "Error", action = "Http404" }
);
And, created the following controller:
public class ErrorController : Controller
{
//
// GET: /Error/Http500
public ActionResult Http500()
{
Response.StatusCode = (int)HttpStatusCode.InternalServerError;
return View("my500");
}
//
// GET: /Error/Http404/Path
public ActionResult Http404(string path)
{
Response.StatusCode = (int)HttpStatusCode.NotFound;
return View("my404", path);
}
}
With all of that, for 500 errors, the my500 view is not being rendered. Instead, it looks like the generic, default Error.aspx view is being displayed again. For 404 errors, I'm getting a YSOD telling me to turn on custom errors in my Web.config. I'm not sure what I'm missing, or if I'm even on the right track.
EDIT: Both views are in Views/Shared