ActionLink Includes Current {id} in URL

asp.net-mvc, c#, routes

Solution

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

Problem

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.

Original source