Reputation: 30671
Is it possible to add "empty" query string parameters with ASP.NET MVC? I need to somehow generate the following url using Html.ActionLink
:
/Home/Index?foo
However this Html.ActionLink("Index", "Index", new {foo = ""})
will output
/Home/Index
Is this possible at all?
Upvotes: 2
Views: 1832
Reputation: 41832
You may have to use Url.Action() instead of Html.ActionLink.
<a href="<%= Url.Action("Index") %>?foo">Index</a>
Upvotes: 3
Reputation: 18877
Now that I understand your problem a little more, no I do not think there is a way to force the ActionLink() function to have an empty string valued query string parameter.
So the next question is... are there any semantic issues with converting a null value for foo
to an empty string?
Upvotes: 1