I have a search form like this:
<form action="@Url.Action("Search", "Items", null, null)" method="POST">
<input type="search" placeholder="Search" name="q" value="some search term">
<input type="hidden" name="city" value="london" />
</form>
This invoke “Search” action method:
public ActionResult Search(string city, string q)
{
...
return View(model);
}
Here I receive both values and search gone fine.
But URL in my browser is:
http://localhost/mysite/item/Search?city=london
as you can see I am missing “q” parameter in URL.
What have I done wrong here?
You form method is POST, so values are not sent via the query string. Change the POST to GET and you should see them.