【发布时间】:2011-02-15 01:37:55
【问题描述】:
我设置了一条搜索路线:
routes.MapRoute(
"Search",
"Search/{q}",
new { controller = "Search", action = "Index" }
);
搜索表单有一个输入框和一个按钮。我希望使用 GET 进行搜索,如下所示。
<% using(Html.BeginForm("Index", "Search", FormMethod.Get))
{%>
<%:Html.TextBox("q")%>
<span class="query-button">
<input type="submit" value="select" /></span>
<% } %>
</div>
SearchController 上的动作是:
public ActionResult Index(string q)
{
// search logic here
return View(new SearchResult(q));
}
网址变成这样: http://localhost:19502/search?q=mvc+is+great
但我希望搜索类似于: http://localhost:19502/search/mvc+is+great
如何设置路由或 Html.BeginForm
【问题讨论】:
标签: asp.net-mvc routing