2010-02-23 142 views
1

Html.ActionLink追加“索引”,动作名称到网址末尾,但我想没有在默认控制器网址中列出的索引动作(希望这是有道理的...)ASP.Net MVC路由URL生成

没曾想:/ ControllerName /索引 通缉:/ ControllerName

下面是我的路由设置:

  routes.MapRoute(
       null, 
       "{controller}/{action}/{id}", 
       null, 
       new { id = @"\d+" } 
      ); 

      routes.MapRoute(
       null, 
       "{controller}/{action}" 
      ); 

      routes.MapRoute(
       null, 
       "{controller}", 
       new { action = "Index" } 
      ); 

      routes.MapRoute(
       null, 
       "", 
       new { controller = "Home", action = "Index" } 
      ); 
+0

我的Html.ActionLinks去索引,不要追加索引链接...即使我提供“索引”作为它链接到的目标行动/ ControllerName – Jimmy 2010-02-23 21:53:39

回答

2

它们翻转各地。这些路线,正如你列出的,应该与你列出的路线相反。

+0

谢谢,为什么我不惊讶它的事情如此简单? – 2010-02-23 21:53:48

+0

是的,你是对的,那是可能的(刚删除我的答案)。在该示例中,将操作定义为默认操作可能非常有用。 +1 – road242 2010-02-23 21:54:53