Map routes works only the default

0

I'm having a problem with my project. I have two routes, the "Default" and a test, but I do not know if it is done correctly because it does not work when they put in the url what I put there, it works only the "Default"

public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.MapRoute(
            "TestRoute",
            "{id}",
            new { controller = "Inicio", action = "Inicio", id = UrlParameter.Optional },
            new { id = @"\d+" } //one or more digits only, no alphabetical characters
        );
        //default route
        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Inicio", action = "Inicio", id = UrlParameter.Optional }
        );
    }
    
asked by anonymous 23.08.2014 / 06:27

1 answer

1

Your two routes are pointing to the same Controller and Action .

See the following route mapping template that I found in this question here

   context.MapRoute(
                "Comment_default",
                "Comment/PostMsg",
                new { controller = "Comment", action = "PostMsg", id = UrlParameter.Optional },
                new[] { "Demo.Web.Controllers" }
            );

            context.MapRoute(
                "Comment_default",
                "Comment/{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                new[] { "Demo.Web.Areas.Comment.Controllers" }
            ); 
    
23.08.2014 / 15:10