1. Öncelikle controller da aşağıdaki ActionResult yazılır:
public ActionResult s404()
{
return View();
}
2. s404.cshtml view i hazırlanır
3. Yeni bir route constraint hazırlanır:
public class hataConstraint:IRouteConstraint
{
#region IRouteConstraint Members
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
{
if (httpContext.Request.RawUrl == "/")
{
return false;
}
return true;
}
#endregion
}
5. Global.asax dosyasında tüm route tanımlamalarının altına ve default routing in üzerine aşağıdaki kod eklenir:
routes.MapRoute("Error", "{*.}", new { controller = "Home", action = "s404" }, new { a = new hataConstraint() });