asp.net mvc url routing:如何获取特定的链接URL

时间:2013-01-10 19:01:04

标签: asp.net-mvc asp.net-mvc-3 url-routing

给出以下路由:

routes.MapRoute(
                "RouteName", // Route name
                "ViewFoo/{FooId}",
                new { controller = "Foo", action = "View"}
            );

对应以下操作方法:

public ActionResult View(string fooId = null)
{
  ...blah...
}

准确地说,如何调用Url.Action()来获取字符串'/ ViewFoo / 4'?或者我需要以某种方式修改路由?

1 个答案:

答案 0 :(得分:0)

Url.Action("View", "Foo", new { FooId = 4 })