Handle Error Attribute at Global Level
Controller:
public class GlobalOverflowExceptionController : Controller
{
//
// GET: /GlobalOverflowException/
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();
}
}
@{
Controller:
public class GlobalOverflowExceptionController : Controller
{
//
// GET: /GlobalOverflowException/
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();
}
}