0

I'm stumped on what seems to be a very strange issue.

In my Razor markup, I have:

@Html.ActionLink("World", "Browse", "Destination") 

But the HTML produced is:

<a href="/Destination/Browse/1/africa-middle-east">World</a> 

Note that the additional data is, in fact, valid data that I'm using in other links. But why the heck does it show up here? I can even verify that the first line produces the second line by inspecting it in the debugger.

I know I'm doing something really stupid here. I just don't see what it is.

1
  • 1
    It comes from the existing route data. Commented Sep 18, 2012 at 20:35

1 Answer 1

1

I guess, it is taking the old route values for building the a tag. check this article for a similar scenario.

Use this overload and try to explicitly pass null as RouteValues and see what changes it brings

public static MvcHtmlString ActionLink( this HtmlHelper htmlHelper, string linkText, string actionName, RouteValueDictionary routeValues ) 

So your code can be re-written as

@Html.ActionLink("World", "Browse", "Destination",null) 

Alternatively you may try to use this version also

<a href="Url.Action("Browser", "Destination")">World</a> 
Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, it is the route data. Looks like the dev that implemented this is using @Html.ActionLink("World", "Browse", "Destination", new { id = "" }, null) in other locations so I used that. Thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.