using System.Collections.Generic;
namespace HelloWorldMvcApp
public class HomeController : Controller
public ActionResult Index()
throw new Exception("When in trouble or in doubt, run in circles, scream and shout.");
protected override void OnException(ExceptionContext filterContext)
if (filterContext.ExceptionHandled == true)
filterContext.ExceptionHandled = true;
ViewBag.Code = filterContext.Exception is HttpException ? ((HttpException) filterContext.Exception).GetHttpCode() : 500;
ViewBag.Exception = filterContext.Exception;
filterContext.Result = View();