Am trying to use ELMAH with MVC4
and configured using NUGET Package for MVC.
It handles all the exceptions happening in my code and am logging it to SQL Server.
Using the Ajax Error function am handling AJAX Exceptions(500) Error too. Everything works fine and redirected Error page overriding OnException in Filter Config
But if the user changes the URL and and if the controller doesnt exist am getting Error and not redirected to the Error page.
Ex:
sitename/test -- Correct URL
sitename/tst ---- Getting Server Error instead redirecting to Error page
What is the correct way to handle 404 using ELMAH and redirecting to friendly 404 page in MVC.
I tried changing the Custom Error with 404 in web.config
but it didn't worked as expected.
By default all Errors other than 404 am re directing to Error page
Am trying to redirect to friendly 404 page rather than server error page.
Any useful links or code will be helpful .Thanks
============================================
Update web.config
<customErrors mode="On">
<error statusCode="500" redirect="/Views/Shared/Error.cshtml"/>
<error statusCode="404" redirect="/Views/Shared/ErrorNotFound.cshtml"/>
</customErrors>