Hi Jak,
You can use view page with controller. Then the Modified web.config as:
<customErrors mode="On" defaultRedirect="Error/UnkownError">
<error statusCode="400" redirect="Error/UnknownError"/>
<error statusCode="404" redirect="Error/PageNotFound"/>
</customErrors>
And Create new Controller 'Error' as:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebSolution.Class;
namespace WebSolution.Controllers
{
public class ErrorController : Controller
{
public ActionResult Error()
{
return View();
}
public ActionResult NotFound()
{
return View();
}
}
}
And In RouteConfig.cs file add following:
routes.MapRoute(
"ErrorCustom", // Route name
"Error/UnknownError", // URL with parameters
new { controller = "Error", action = "Error" } // Parameter defaults
);
routes.MapRoute(
"ErrorNotFound", // Route name
"Error/PageNotFound", // URL with parameters
new { controller = "Error", action = "NotFound" } // Parameter defaults
);
Now try the above approch.
Posted On:
28-Dec-2015 00:36