If you want to handle exception at the controller level you will create a class for that inside the controller that will override the OnException method to log errors
This is the view that will show the error in detail it is strongly typed
You need to set the custom error mode on for error logging as per as your requirement
<customErrors mode="On"/>
After doing that where ever the exception occurs the detail page gets showed
using System;
using System.Data.Common;
using System.Web.Mvc;
namespace ExceptionHandlingMVC.Controllers
{
[HandleError]
public class ExceptionHandlingController : Controller
{
public ActionResult TestMethod()
{
throw new Exception("Test Exception");
return View();
}
}
}
0 Comment(s)