in this URL..
Please first two steps can anybody explain me?
The System.Web.Mvc.dll comes with the HandleErrorAttribute class, which contains..wait for it…the HandleError attribute. This information won’t be important until later in this series, but the HandleErrorAttribute class inherits from the FilterAttribute class, and implements the IExceptionFilter interface – the interface requires a method with the following signature.
public virtual void OnException(ExceptionContext filterContext);
Do i need to create Interface?
where Do I need to write OnExceptoin?
thanks
You don’t need to create any interface, nor worry about the
OnExceptionmethod or its implementation. All you need to do is decorate your controller with the[HandleError]attribute, like so:Then go ahead and write some actions inside this controller that might throw an exception and instead of the YSOD (Yellow Screen of Death) you will see a custom error page that you’ve configured. You also need to activate custom errors in your web.config:
By default the
~/Views/Shared/Error.aspxview will be rendered in case of exception. You could define specific error views based on the exception being thrown:means that if an
ApplicationExceptionis thrown, the~/Views/Shared/AppErrorPage.aspxview will get rendered.That’s what the framework provides you out-of-the-box. If this is not enough for your needs and doesn’t work in your specific scenario you might start worrying about implementing a custom
IExceptionFilter.