1

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?

Palak.Maheria
  • 1,497
  • 2
  • 15
  • 32
Sascha
  • 10,231
  • 4
  • 41
  • 65

1 Answers1

0

A CatchAll - Route solved the problem. A question with an answer which made me find the solution:

MVC 4 catch all route never reached

Community
  • 1
  • 1
Sascha
  • 10,231
  • 4
  • 41
  • 65