I am using RC2
Using URL Routing:
routes.MapRoute(
\"Error\",
\"{*url}\",
new { controller = \"Errors\", action = \"N
My shortened solution that works with unhandled areas, controllers and actions:
Create a view 404.cshtml.
Create a base class for your controllers:
public class Controller : System.Web.Mvc.Controller
{
protected override void HandleUnknownAction(string actionName)
{
Http404().ExecuteResult(ControllerContext);
}
protected virtual ViewResult Http404()
{
Response.StatusCode = (int)HttpStatusCode.NotFound;
return View("404");
}
}
Create a custom controller factory returning your base controller as a fallback:
public class ControllerFactory : DefaultControllerFactory
{
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
{
if (controllerType != null)
return base.GetControllerInstance(requestContext, controllerType);
return new Controller();
}
}
Add to Application_Start()
the following line:
ControllerBuilder.Current.SetControllerFactory(typeof(ControllerFactory));