Only the first parameter value is received during a controller method call using Url.action.
I am calling a controller method using Url.action
like,
location.href = '@Url.Action("Display", "Customer", new { username = "abc",name = "abcdef",country = "India",email = "abc@hmail.com",phone = "9456974545"})';
My controller method,
public void Display(string username, string name, string country, string email, string phone)
{ }
In this method, I can only get the value of the first parameter ( username
). It does not receive any other parameter values ββthat are passed. All other values ββare zero.
Please suggest me what is wrong?
By default, every content (which is not IHtmlString
) emitted using the @ block is automatically HTML encoded
by Razor.
So, @Url.Action()
also coded and you get plain text. And &
encoded as&
If you don't want to encode you should use @Html.Raw(@Url.Action("",""))
.
The answer to your question:
location.href = '@Html.Raw(@Url.Action("Display", "Customer", new { username = "abc",name = "abcdef",country = "India",email = "abc@hmail.com",phone = "9456974545"}))';
Hope it helps
There is a problem with '&' being encoded in & amp; '
the model binder does not recognize this value. You need to prevent this encoding by referencing the image with the Html.Raw function.
Use '@ Html.Raw (Url.Action ......)'