2014-02-25 126 views
0

請你幫我弄清楚下面的剃刀語法有什麼問題。我正試圖輸出一個鏈接到MVC動作的錨標籤。ActionLink不輸出正確的路徑

剃刀語法:

@Html.ActionLink("Back to Reports List", "Index", "Reports") 

輸出在瀏覽器:

<a href="/">Back to Reports List</a> 

,而不是:

<a href="/Reports/Index">Back to Reports List</a> 

任何想法?

+0

你見過嗎? :http://stackoverflow.com/questions/7439375/having-a-problem-outputting-the-correct-url-from-an-actionlink –

回答

2

請顯示您的路線配置。基於此生成的網址。 有可能您的路線配置以:

routes.MapRoute(
     name: "Default", 
     url: "{controller}/{action}/{id}", 
     defaults: new { controller = "Reports", action = "Index", id = UrlParameter.Optional } 
); 
+0

謝謝彼得。現貨 - 這是問題所在。我不知道ActionLink檢查路由配置以輸出路徑!非常感謝 –