In MVC we have different kind of filters available for different purpose.
One of the filters that is available is for handling the errors known as the error filter.
We can handle that error in the same action or by redirecting it to another view or page we have made for handling and displaying errors.
[HandleError]
public class ActionFilterDemoController : Controller
{
public ActionResult Index()
{
throw new NullReferenceException();
}
public ActionResult About()
{
return View();
}
}
We also can navigate it to some other view on finding the error.
[HandleError]
public class ActionFilterDemoController : Controller
{
public ActionResult Index()
{
return RedirectToAction('Error');
}
public ActionResult About()
{
return View();
}
}
0 Comment(s)