这是当前为属性详细信息页面生成的 url。
http://localhost:61346/Property/Details?strap=0001020005
我想读这个
http://localhost:61346/Property/Details/0001020005
这是我注册的路线。这在 MVC3 中设置简单吗?解释如何为此格式设置“RegisterRoutes”的额外要点
http://localhost:61346/Property/0001020005
<--只是隐藏动作名称
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Property", // Route name
"{controller}/{action}/{ParcelId}", // URL with parameters
new { controller = "Property", action = "List", ParcelId = 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
);
routes.MapRoute(
"Details", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Property", action = "Details" } // Parameter defaults
);
}