我想让我的基本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" }
);
}
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用.我怎样才能完成我想做的事情?
我对MVC的经验很少,所以如果任何一个没有意义,我会道歉.
我正在使用Visual Studio 2010中的一个Web应用程序,它的mvc3.我试图弄清楚如何发布它,并通过各种指示我尝试将View/Home/Index设置为起始页面.这是个坏主意.现在没有任何工作,甚至尝试查看网站(我用F5调试)没有正确加载.
我不知道之前的起始页是什么,或者如何撤消它.我对网络开发很陌生,现在有点迷失.如何获取我的起始页?