I am trying to create a custom error page for 404 errors. I have implemented the Application_Error method in Global.asax.cs. For the most part this works great, but the method isn’t getting called for URLs with 4 or more path segments.
The specific URL that I’m having trouble with is:
http://localhost/Area/Controller/Action/ID
If I remove the ID, my custom 404 age loads fine. The problem seems to be having 4 levels in my path (/Area/Controller/Action/ID). Any ideas?
I suspect your routes don’t account for a URL with 4 parts. Try adding a catch all route as your last route to test this:
Including (some of) your routes in your RouteConfig.cs question might also help.