How can we do exception handling in mvc

In the controller you can override the “OnException” event and set the “Result” to the view name which you want to invoke when error occurs. In the below code you can see we have set the “Result” to a view named as “Error”.

We have also set the exception so that it can be displayed inside the view.

To display the above error in view we can use the below code

results matching ""

    No results matching ""