【发布时间】:2012-02-29 07:42:31
【问题描述】:
我正在尝试实现这样的路线:
http://mysite.com/portfolio/landscape
http://mysite.com/portfolio/friends 等等...
所以我写了:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"DefaultIndex", // Route name
"{controller}/{id}", // URL with parameters
new { action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
效果很好,我可以拥有我的路线 /portfolio/landscape,但我的具有 SignIn、SignOut、Index 操作的帐户控制器不起作用,因为它每次都会被重定向到 Index。
两个都可以吗?
提前谢谢你
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-3 routes