Hi. I have a simple search form in my master page and a serach controller and view. I'm trying to get the following route for the string search term "myterm" (for example): root/search/myterm
The form in the master page :
<% using (Html.BeginForm("SearchResults", "Search", FormMethod.Post, new { id = "search_form" }))
{ %>
<input name="searchTerm" type="text" class="textfield" />
<input name="search" type="submit" value="search" class="button" />
<%} %>
The Controller Action:
public ActionResult SearchResults(string searchTerm){...}
The Route I'm Using :
routes.MapRoute(
"Search",
"search/{term}",
new { controller = "Search", action = "SearchResults", term = (string)null }
);
routes.MapRoute(
"Default",
"{controller}/{action}",
new { controller = "Home", action = "Index" }
);
I'm always getting the url "root/search" without the search term, no matter what search term I enter.
Thanks.