I noticed that the Html.BeginForm () method encodes the provided routeValues parameters into the action attribute of the FORM tag. This works well with the POST method. But if the method is GET, all parameters in the action URL are deleted by the browser (tested in IE8 and Firefox 3.0.7).
For example, this code in sight
<% using (Html.BeginForm("TestAction", "TestController", new { test = 123 }, FormMethod.Get)) { Response.Write("<input type='submit'>"); }; %>
gives such HTML
<form action="/TestController/TestAction?test=123" method="get"> <input type='submit'> </form>
But after submitting the form the URL became / TestController / TestAction not / TestController / TestAction? test = 123 (parameter lost).
Now I use the Html.Hidden () call group instead of the routeValues parameter, but I wonder if there is another workaround? Should it be considered a bug in MVC that will ever be fixed?
parameters asp.net-mvc get-method
Alexander Prokofyev
source share