2010-10-04 67 views

回答

2

是的,你可以通过routeconstraints来做到这一点。可以将常量传递给global.asax中的Maproutes方法。如果u有可以通过正则表达式来处理约束,其中正则表达式告诉文档ID应该是数字匹配这条路线u能写出像

routes.MapRoute(
       "strict", 
       "{controller}.mvc/{docid}/{action}/{id}", 
       new {docid = "",action = "Index", id = ""}, 
       new { docid = @"\d+"} 

      ); 

。然而 U可以写自己的乌尔班实现IRouteConstraint接口和类的对象可以作为routeconstraint行事乌尔航线

看看这里,看看ü可以如何实现IRouteConstraint

ASP.NET MVC2 Parent Controller Not Redirecting