有人可以告訴我這個ActionLink有什麼問題嗎?問題與@ Html.ActionLink
@Html.ActionLink(posts.Title, "PostDetails", "Blogs", new { id = posts.PostID })
我期待這個鏈接去:
而是我看到在Firefox如下:
它甚至不會去博客控制器。
有人可以告訴我這個ActionLink有什麼問題嗎?問題與@ Html.ActionLink
@Html.ActionLink(posts.Title, "PostDetails", "Blogs", new { id = posts.PostID })
我期待這個鏈接去:
而是我看到在Firefox如下:
它甚至不會去博客控制器。
您確定您在調用正確的重載方法嗎? 如果你錯過了一個參數,它會給出不同的含義。
http://msdn.microsoft.com/en-us/library/dd505040.aspx
請仔細檢查,如果你缺少一個PARAM。
好吧,該鏈接整理了一切...我必須提供ActionLink中的最後一個參數... @Html。 ActionLink(posts.Title,「PostDetails」,「Blogs」,new {id = posts.PostID},null) –
我經常犯這個錯誤。您的原始代碼使用'routeValues =「Blogs」,htmlAttributes = new {id = posts.PostId}',因爲這是錯誤的超載。 –
它與路線值傳遞的方式做,而不是使用:
@Html.ActionLink(posts.Title, "PostDetails", new {Controller="Blogs", id = posts.PostID })
thx ...我現在清楚了...並且從你的答案中學到了差異化的方式... –
這仍然是錯誤的...它應該是'new {Controller =「Blogs」,id = posts.PostId }' –
謝謝,你是對的會改變它。 – Turnkey
做你的路由規則是什麼樣子? –
我正在使用默認的...我不認爲這樣它的goona需要新的路線... –