我希望将我的基本网址转到某个在线商店的特定类别(如果这有所作为,请登录NopCommerce在线商店)。该类别的网址是:http://myUrl.com/c/6
如何在MVC应用程序上设置默认页面?
阅读一些职位,包括斯科特Gutherie的帖子about MVC routing后,我想我可以在下面的代码只需添加到我的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的经验,所以我很抱歉,如果这些没有任何意义。
该代码发生了什么?看着当前的路线,你必须有更多的路由规则,因为它不遵循那里的命名结构。你有可能发布整个注册路线部分? –
用完整的RegisterRoutes方法更新。当我转到基本URL时,它会转到之前的相同页面。 –