I have an ASP.Net MVC 4 view that is supposed to conditionally render an ActionLink. However, the ActionLink does not render in the final output. To diagnose the issue, I added text before and after the desired ActionLink, and also duplicated the ActionLink code outside the if body.
The result is that the ActionLink code outside of the if body, as well as the before/after text, renders but not the ActionLink I actually want.
@Html.ActionLink("NEXT", "_NextPage")
@if (true /*!Model.IsFinalPage*/) {
<text>Pre</text>
Html.ActionLink("NEXT", "_NextPage");
<text>Post</text>
}
Output:
NEXT Pre Post
(NEXT is an appropriate link)
The action-link needs the @ to work here.
In razor, plain-old Html.ActionLink returns the html-string, but it doesn’t get written to he buffer without the @. so
would be the same as