I have created one demo for show our custom error page in MVC 5. I am having success when entering two slashes, but when I am entering more than two slashes, I am not getting my custom error page, but rather a MVC error as shown below.
HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
This is how my Web.config
file looks like.
<customErrors mode="On" defaultRedirect="~/Error">
<error redirect="~/Error/NotFound" statusCode="404" />
<error redirect="~/Error/Forbidden" statusCode="403" />
</customErrors>
This is my ErrorController
.
public ViewResult NotFound()
{
return View();
}
My current setup works fine when I enter the URL below.
But when enter one of the URLs below, my custom error page is not displayed.
http://localhost:14360/search/fdsfdf/sdsdsd/asdsadasd/dasdsad
http://localhost:14360/search/fdsfdf/dsads/fe