I am new to MVC. I was reading about error logging in MVC.
I came to know about HandleErrorAttribute. I have a question regarding that.
Let's say we placed the HandleErrorAttribute in a Action.
<!-- language: c# --> [HandleError(View = "Error")] public ActionResult Index6() { throw new Exception("Something terrible happened."); return View(); } and turned on custom errors in web.config
<customErrors mode="On"> </customErrors> Now if any undandled exception occured in that "Index Action", it will show the Error.cshtml which is in "Views/Shared" folder.
But we can have the same behavior just setting some configuration under customErrors section in web.config. like
<customErrors mode="On" defaultRedirect="~/Error"> <error statusCode="404" redirect="~/Error/NotFound" /> </customErrors> Just to mention, I have a "ErrorController" with "Index" action that returns "Views/Shared/Error.cshtml" view.
So, my question is why should we use HandleErrorAttribute? is there any benefits of using that?
Thanks