Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Example of using NavigationRoutes
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
// You need to add this using statement to use the MapNavigationRoute extension method.
using NavigationRoutes;
namespace MvcApplication13
public class RouteConfig
public static void RegisterRoutes(RouteCollection routes)
//This is the first Navigation route
// RouteName DisplayName Url Defaults
routes.MapNavigationRoute("Home-navigation", "Home" , "", new { controller = "Home", action = "Index" });
//This is the second Navigation route
// RouteName DisplayName Url Defaults
routes.MapNavigationRoute("About-navigation", "About" , "about", new { controller = "Home", action = "About" });
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }

Hi, how do I create the children dynamically?

dedlfix commented Apr 30, 2013

Use the strongly typed version

var fooNavRoute = routes.MapNavigationRoute<FooController>("Foo", f => f.Index());
// repeat following as often as needed
fooNavRoute.AddChildRoute<FooController>("Child", f => f.Child());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment