Nothing
Nothing

Reputation: 2642

Add more routing to asp.net MVC Global.asax

I have one map route like :

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

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



    }

but I want to add more route URL , how can I do that ?

Upvotes: 8

Views: 12623

Answers (1)

Bala R
Bala R

Reputation: 108937

Just add another MapRoute()

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

routes.MapRoute(
    "SecondRoute",
    "{controller}/{action}/{tags}",
    new { controller = "Products", action = "Index", tags = "" }
);

I suggest you go through this excellent post on routing by The Gu.

Upvotes: 9

Related Questions