Вам понадобится универсальный маршрут, который регистрируется последним, а затем отвечает 404 после того, как контроллер зарегистрировал ошибку:
routes.MapRoute(
"NotFound",
"{*url}",
new {controller = "NotFound", action = "index"}
)
public class NotFoundController: Controller
{
public ActionResult Index(string url)
{
Log.Warn(this, string.Format("404 Request Not Found: {0}", url));
Response.StatusCode = 404;
var model = new NotFoundViewModel
{
Title = "Sorry but the page you are looking for does not exist",
Message = new HtmlString("Please <a href='/'>click here</a> to return to the home page")
};
return View("404", model);
}
}