Asp.net mvc 2 mvc.net路由:maproutes中的RouteValue

Asp.net mvc 2 mvc.net路由:maproutes中的RouteValue,asp.net-mvc-2,routes,url-routing,Asp.net Mvc 2,Routes,Url Routing,我需要像/controller/verb/noon/id这样的URL,我的操作方法是动词+名词。例如,我希望/home/edit/team/3点击操作方法 public ActionResult editteam(int id){} 我的global.asax文件中有以下路径 routes.MapRoute( "test", "{controller}.mvc/{verb}/{noun}/{id}", new

我需要像
/controller/verb/noon/id
这样的URL,我的操作方法是动词+名词。例如,我希望
/home/edit/team/3
点击操作方法

public ActionResult editteam(int id){}
我的global.asax文件中有以下路径

routes.MapRoute(
              "test",
              "{controller}.mvc/{verb}/{noun}/{id}",
              new { docid = "", action = "{verb}"+"{noun}", id = "" }


            );

URL与路由正确匹配,但我不知道应该在何处构造作为被调用的操作方法名称的操作参数。

尝试以下操作,将其用作路由:

routes.MapRoute(
              "HomeVerbNounRoute",
              "{controller}/{verb}/{noun}/{id}",
              new { controller = "Home", action = "{verb}"+"{noun}", id = UrlParameter.Optional }
            );
然后,您只需将actionresult方法:

public ActionResult editteam(int id){}
进入Controllers/HomeController.cs,当URL与提供的路由匹配时,将调用它。

尝试:

我不知道有什么方法可以自动为所有路线钩住它,但在您的情况下,您可以为该条目执行以下操作:

routes.MapRoute(
   "test",
   "{controller}.mvc/{verb}/{noun}/{id}",
   new { docid = "", id = "" }
   ).RouteHandler = new VerbNounRouteHandler();

恐怕这是路由参数的默认值,而不是运行时指定的动词和名词的实际值。使用此路由将在每次匹配此路由时,在路由值字典的操作字段中生成{verb}{noon}值。您是否可以使用自定义控制器映射,就像您在结尾使用.MVC一样,或者甚至使用硬字符串:/custom/{verb}/{noon}/{id},然后如我所说,使用主控制器中的actionresults?直接通过?如果这不是您要查找的信息,请尝试澄清问题,因为我正在努力了解您可能还想了解的其他信息。我需要的是,如果我有url,如/edit/team/1 route value dictionary应该在操作键处包含editteam。如果我有像manage/team/1这样的url,路由值字典应该有manageteam-in-action键。Maproutes只能定义默认值,不能定义参数的动态值(在我的例子中是动词和名词)。我认为埃格拉修斯给出的解决方案应该有效。
routes.MapRoute(
   "test",
   "{controller}.mvc/{verb}/{noun}/{id}",
   new { docid = "", id = "" }
   ).RouteHandler = new VerbNounRouteHandler();