Solved. To point all non-existing urls to your error page, do the following:
Add the code below at the end of your RouteConfig.cs file:
public static void RegisterRoutes(RouteCollection routes) { // Default routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); // Add this code to handle non-existing urls routes.MapRoute( name: "404-PageNotFound", // This will handle any non-existing urls url: "{*url}", // "Shared" is the name of your error controller, and "Error" is the action/page // that handles all your custom errors defaults: new { controller = "Shared", action = "Error" } ); }
Add the code below to your Web.config file:
<configuration> <system.webServer> <modules runAllManagedModulesForAllRequests="true"></modules> </system.webServer> <system.web> <httpRuntime relaxedUrlToFileSystemMapping="true" /> </system.web> </configuration>
That should point all the non-existing urls such as (/ad/asd/sa/das,d/asd,asd.asd+dpwd'=12=2e-21) to your error page.