@Url.Action adding "amp;" between parameters creating nulls in the controller?
Url.Action
isn't the problem - it's how you use it.
You're using @
- this is used for inlining the results of a piece of server-side code in a (X)HTML page. In a (X)HTML page, entities must be properly encoded, turning your &
into a &
. This is the exact correct behaviour - that's how it's supposed to be inlined in either text or an attribute, for example (which is why you use it in e.g. <a href="@...">
).
However, you're trying to inline the raw value, rather than the encoded value - because you're not trying to emit HTML, you're emitting raw text. Html.Raw
does just that:
@Html.Raw(Url.Action("Test", new { arg1 = "Hi!", arg2 = "there." }))