8.1.2 Refining the URL Scheme; Listing 8-3. The New URL Scheme in the RouteConfig.cs File
This commit is contained in:
parent
a353aacadc
commit
f2b64d578f
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user