Exception Handling and Creating Exception Logs in Asp.net Mvc :-
As per a Developer we have to face issue of handling Exception Effectively.In this Article we will see how to handle exceptions effectively in Asp.Net MVC.So Let's See how it works:-
So basically in a MVC Project we often use many controllers for making our web project functional.So one way is to handle exception separately on all of them or we can simple use a Base Controller. A Base controller can be told as a parent controller from which all other controller will inherit.So in that way Exception handling performed on Base Controller will get applied on all controllers which inherits from this controller.
So you can see a Base Controller which has OnException Method to handle all the exceptions
This Error Log Method is used to add Logs to your Log File so that you can check your exceptions for debugging in a better way.
Inherit Controller from Base Controller:-
So after we have successfully set up OnException Action Method and Error Log File Now we can inhrit controllers from this Base Controller.
So this is how you can use your base controller with all controllers simply by inheriting.Now whenever any exception will occur on you Blog Controller or your controller it will Log its Details in Log Files.