views:

262

answers:

2

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?

+1  A: 

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?

NickLarsen
Yes, I want to handle null in a different way from empty string to avoid passing some dummy values such as space or anything else. I think the other response is the way to go.
korchev
+3  A: 

You may have to use Url.Action() instead of Html.ActionLink.

<a href="<%= Url.Action("Index") %>?foo">Index</a>
Matt