HandleErrorAttribute at controller level
Controller:
[HandleError(ExceptionType = typeof(System.OverflowException), View = "overflowexception")]
public class OverflowExceptionController : Controller
{
//
// GET: /OverflowException/
public ActionResult Index()
{
return View();
}
public ActionResult overflowexception()
{
int value = int.MaxValue + int.Parse("1");
if (value < 0)
{
throw new OverflowException();
}
else
{
ViewBag.Result = value;
}
return View();
}
public ActionResult dividebyzeroexception()
{
int a = 10;
int b = 0;
int c = a / b;
return View();
}
public ActionResult overflowexception1()
{
int value = int.MaxValue + int.Parse("1");
if (value < 0)
{
throw new OverflowException();
}
else
{
ViewBag.Result = value;
}
return View();
}
}
View:
@{
ViewBag.Title = "overflowexception";
}
<h2>overflowexception</h2>
<h2>@ViewBag.Result</h2>
Screenshot:
Conclusion:
Created the common overflowexception error page for multiple actions in multiple controller