我希望我的基础URL可以指向在线商店的特定类别(如果这是NopCommerce在线商店,则不同的),该类别的URL为:http://myUrl.com/c/6
阅读了几篇文章,包括Scott Gutherie的有关MVC路由的文章后,我认为我只需要在Global.ascx.cs文件中添加以下代码:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//register custom routes (plugins, etc)
var routePublisher = EngineContext.Current.Resolve<IRoutePublisher>();
routePublisher.RegisterRoutes(routes);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Catalog", action = "Category", id = 6 },
new[] { "Nop.Web.Controllers" }
);
}
但这似乎不起作用。我该如何实现我想做的事情?
我对MVC的经验很少,所以如果有什么不合理的地方,请谅解。