diff --git a/SportsStore/SportsStore.WebUI/App_Start/RouteConfig.cs b/SportsStore/SportsStore.WebUI/App_Start/RouteConfig.cs index 2122a42..63cc9db 100644 --- a/SportsStore/SportsStore.WebUI/App_Start/RouteConfig.cs +++ b/SportsStore/SportsStore.WebUI/App_Start/RouteConfig.cs @@ -5,6 +5,7 @@ using System.Web; using System.Web.Mvc; using System.Web.Routing; using System.Web.UI; +using Ninject.Infrastructure.Language; namespace SportsStore.WebUI { @@ -14,17 +15,49 @@ namespace SportsStore.WebUI { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); - routes.MapRoute( - name: null, - url: "Page{page}", - defaults: new { Controller = "Product", action = "List"} - ); + routes.MapRoute(null, + "", + new + { + controller = "Product", action = "List", + category = (string)null, page = 1 + }); - routes.MapRoute( - name: "Default", - url: "{controller}/{action}/{id}", - defaults: new { controller = "Product", action = "List", id = UrlParameter.Optional } - ); + routes.MapRoute(null, + "Page{page}", + new + { + controller = "Product", + action = "List", + category = (string)null + }, + new + { + page = @"\d+" + }); + + routes.MapRoute(null, + "{category}", + new + { + controller = "Product", + action = "List", + page = 1 + }); + + routes.MapRoute(null, + "{category}/Page{page}", + new + { + controller = "Product", + action = "List" + }, + new + { + page = @"\d+" + }); + + routes.MapRoute(null, "{controller}/{action}"); } } }