1

Below url works fine and redirects to the custom error page for page not found.

http://localhost:50298/a/b/c  

But when the Url is longer like the below one

http://localhost:50298/a/b/c/d

then it shows the default error page instead of showing the custom error page with message "HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."

In the web.config below is added . It works fine for shorter url with max 3 "/" but it doesn't works when it is more than 3.

</system.web>
    <customErrors mode="On" defaultRedirect="~/Error/Index">
        <error statusCode="404" redirect="~/Error/NotFound"/>
    </customErrors>
</system.web>

Is there any setting required to be done to show the custom error page for longer urls instead of the default iis error page ?

Shubham kumar
  • 79
  • 2
  • 11
  • Create a catch-all route and place it as the last route definition (refer [ASP.NET MVC - Catch All Route And Default Route](https://stackoverflow.com/questions/4001081/asp-net-mvc-catch-all-route-and-default-route) fro an example –  Jul 11 '18 at 05:35
  • yes Did that and its now working fine. Thanks @StephenMuecke :) – Shubham kumar Jul 11 '18 at 06:16

0 Answers0