Asp.net mvc bool的MVC路由约束

Asp.net mvc bool的MVC路由约束,asp.net-mvc,routes,constraints,boolean,Asp.net Mvc,Routes,Constraints,Boolean,对于通过bool的MVC路由约束,什么是有效的正则表达式?例如,我有以下路线: routes.MapRoute("MenuRouteWithExtension", "Menu.mvc/{action}/{projectId}/{dealerId}/{isGroup}", new { controller = "Menu", action = "RedirectUrl", projectId = "", dealerId = "", isGroup = ""

对于通过bool的MVC路由约束,什么是有效的正则表达式?例如,我有以下路线:

routes.MapRoute("MenuRouteWithExtension",
    "Menu.mvc/{action}/{projectId}/{dealerId}/{isGroup}",
     new { controller = "Menu", action = "RedirectUrl",
           projectId = "", dealerId = "", isGroup = "" }
     new { projectId = @"\d+", dealerId = @"\d+", isGroup = @"???" });
基本上,我需要知道什么可以代替???在上面的代码示例中

这样,另一端的操作可以使用bool类型,如:

public ActionResult RedirectUrl(int projectId, int dealerId, bool isGroup)
提前感谢您的投入

isGroup = @"^(true|false)$"
所以

大小写不重要,因此应接受
True
,以及
falSE

另外,我在regex值上添加了
^
$
,这样它们就不会匹配,例如
blahtrueblah

不应该dealerId=@“^\d$+”,被dealerId=@“^\d+$”,只需切换最后两个字符
routes.MapRoute(
  "MenuRouteWithExtension",
  "Menu.mvc/{action}/{projectId}/{dealerId}/{isGroup}",
  new
  {
    controller = "Menu",
    action = "RedirectUrl",
    projectId = "",
    dealerId = "",
    isGroup = "" //Possibly set this to 'true' or 'false'?
  },
  new
  {
    projectId = @"^\d+$",
    dealerId = @"^\d+$",
    isGroup = "^(true|false)$"
  }
);