I have a simple form for searching for a user
<p>Enter a user's id number to search:</p>
<% using (Html.BeginForm("Search", "UserAdmin", FormMethod.Get)) { %>
<%= Html.TextBox("id") %>
<input type="submit" value="Search" />
<% } %>
I want this link to go to useradmin/search/{id} but the link is rendered as useradmin/search?id={id}
Both urls are valid and map to my action as I would expect, I just think the former is neater and want that style to be used.
Update:
Based on Michael Gattuso's answer I have this as a working solution. Not elegant, but it works.
<p>Enter a user's id number to search:</p>
<% using (Html.BeginForm("SearchPost", "UserAdmin")) { %>
<%= Html.TextBox("id") %>
<input type="submit" value="Search" />
<% } %>
public ActionResult Search(string id)
{
var result = _Service.SearchForUsers(id);
return View(result);
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SearchPost(string id)
{
return RedirectToAction("Search", new { id = id });
}