ActionLink的包括当期{ID}在网址 [英] ActionLink Includes Current {id} in URL
问题描述
目前显示在我的浏览器的页面是:的http://本地主机:19255 /对象/浏览/ 1
$ B $
@ Html.ActionLink(...,浏览,对象)
$:乙本网页上的链接与创建b
$ b
但生成的链接居然是: /对象/浏览/ 1
我发生了什么事的理解是,MVC看到我的路线有一个{ID}部分,我没有提供。所以说干就干,包括从当前页面的{ID}部分。
很公平,但我怎么没有创建一个链接?我试图空
和新{ID = NULL}
,但既不工作。
< DIV CLASS =h2_lin>解决方案
虽然没有以下工作:
@Html。 ActionLink的(...,浏览,对象,NULL)//没有任何效果
@ Html.ActionLink(...,浏览,对象,新{ID =空})//错误
下解决该问题:
@ Html.ActionLink(...,浏览,对象,新{ID =})//无ID传递
The page currently displayed in my browser is: http://localhost:19255/Object/Browse/1
.
A link on this page is created with: @Html.ActionLink("...", "Browse", "Object")
But the generated link is actually: /Object/Browse/1
My understanding of what's happening is that MVC sees my route has an {id} portion, which I did not supply. So it went ahead and included the {id} portion from the current page.
Fair enough, but how do I create a link without it? I tried null
, and new { id = null }
but neither worked.
While neither of the following work:
@Html.ActionLink("...", "Browse", "Object", null) // Has no effect
@Html.ActionLink("...", "Browse", "Object", new { id = null }) // Error
The following solves the issue:
@Html.ActionLink("...", "Browse", "Object", new { id = "" }) // No ID is passed
这篇关于ActionLink的包括当期{ID}在网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!