I have an input box where in the value entered will be POSTed to the Action parameter. But I also want the value to reflect on the url like this:
www.my-site.com/search/myquery
Any idea on how to achive this?
Here are the codes..
Search Form
<% using(Html.BeginForm("Index", "Search")) { %>
<%: Html.TextBox("query", "Enter Keyword") %>
<% } %>
Global Asax
routes.Add("Search", new Route(
"Search/{query}",
new { controller = "Search", action ="Index", query="" }
));
Controller
public ActionResult Index(string query)
{
return new EmptyResult()
}