If we have asp.net mvc 5.0 application and we are searching some different page on browser then we will get the exception message.
“The resource cannot be found” I.e HTTP 404 status code.
To display this error message as user friendly we can install the “NotFoundMVC” Nuget package in Visual studio like this
Now go to the web config file and delete the this line of code. This is the problem in this NuGet package, which is creating some invalid code in web config file.
Now this package will create the Not found page for you.
This will also add the required code in web config file like this
Now run the application with wrong controller/Action name. It will give user friendly error message like this
Limitation of Control
This control does not handle the other error message. It will handle on status code 404. For other error we have to implement separate error handle approach.
I hope this post will help to implement the user friendly error message for http status code 404.