HandleErrorAttribute in MVC is used to display friendly error pages to user when something goes wrong in the application. Let's create a simple exception in the application to explore HandleErrorAttribute.
I have created a demo app using 'Internet' template, create the same you too to explore.
Now, open the 'Home' controller and throw a new exception from 'Index' action:
In above image, I've added a simple line to throw an error whenever application reaches to 'Home' controller and 'Index' action. Now, run the application on localhost and also on production server to view the error.
I've deployed the application on my local production server using domain 'foo.com' to look yellow death screen (error page) closely on production and development servers. If you look at the error pages and compare the results of green rectangular regions, MVC smartly hiding things on production server but this is not enough from user point of view.
Let's open the 'Web.config' file and add <customErrors mode="On"/>









Manav PandyaPosted Dec 14, 2016, 9:29 AM
But sir which method do you suggest to apply in MVC , as globle exception handling throughout application
Manav PandyaPosted Dec 14, 2016, 9:28 AM
Great article on exception handling sir