Search code examples
asp.net-mvcasp.net-mvc-2routesurl-routingmaproute

Map URL to empty route in ASP.NET MVC 2 from URL. URL displays blank page


If URL is
http://localhost:54027/test1/test2/home
It shows home page

If URL is
http://localhost:54027/test1/test2/
It shows BLANK page


Following are the routes we have used

routes.MapRoute(
              "HomePage",
              "Test2",
              new { controller = "Home", action = "Index", id = "", title = UrlParameter.Optional }
          );
            routes.MapRoute(
            "ProductDetails", // Route name
            "Test2/", // URL with parameters
            new { controller = "Home", action = "Index", id = "", title = UrlParameter.Optional } // Parameter defaults
            );
            routes.MapRoute(
                "Default",
                "Test2/{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", id = "1" }
            );



If we try following URL it works fine
http://localhost:54027/test1/test2/'

routes.MapRoute(
            "ProductDetails", // Route name
            "Test2/{'}", // URL with *** ' *** parameters
            new { controller = "Home", action = "Index", id = "", title = UrlParameter.Optional } // Parameter defaults
            );

Solution

  • We have created a dummy page as blank page and added Response.Redirect to home page This is not the solution to the problem, but we worked around it.