1

I have a bit of code that looks like that:

@Html.ActionLink("linkText", "pageName", new { param1 = ViewBag.Param1, name = ViewBag.CurrentName })

When ViewBag.CurrentName contains something, the link looks like this:

Url/pageName?param1=val1&name=val2

But if CurrentName is empty string "", instead of including it, it just ignores it like this:

Url/pageName?param1=val1

The problem is, that once in the controller when the link is clicked, the parameter doesn't contain an empty string, but a null. This causes problem, because I want to have a different behaviour depending on if the value is null, or if it is a real string (empty or not).

How can I force the @Html.ActionLink to include empty parameters too?

Kaito Kid
  • 983
  • 4
  • 15
  • 34

0 Answers0