I have implemented custom error pages in an MVC4 application. Basically I've added the following to my Web.Config file:
<customErrors mode="On" defaultRedirect="Error">
<error statusCode="404" redirect="~/Error/NotFound"/>
<error statusCode="500" redirect="~/Error/Index"/>
</customErrors>
Unfortunately, if someone uses a request that adds a path to a route the redirect doesn't take place. For example I have a Document method that takes an ID on the controller Content. The following request is valid:
/Content/Document/1
I get the 404 displayed when someone calls an url like this:
/BlaBla
/Content/BlaBla
Some users manage to add /BlaBla
after the ID:
/Content/Document/1/Blabla
This is the case where my custom 404 page is not shown. How can I handle this?