请帮我翻译一下,我正在制作MVC网站,我有一个搜索页面和另一个在首页上的搜索表单。我想在从首页点击搜索按钮时调用相同的搜索页面控制器。以下是我的首页上的按钮:
<span class="input-group-btn">
<button class="btn btn-info" type="button" id="addressSearch"
onclick="location.href='<%: @Url.Action("List", "Search") %>'">
Search</button></span>
列表是我从搜索页面执行搜索的操作,Search是控制器名称。当我点击上面的按钮时,它以如下形式返回url:
http://localhost:52050/<%:%20/Search/List%20%>
显示坏请求。我怀疑这是来自我的路由,但我不确定如何实现这一点,请帮忙解决。以下是我的路由设置:
routes.MapRoute(
name: null,
url: "Page{page}",
defaults: new { Controller = "Search", action = "List" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new
{
controller = "Home",
action = "Index",
id = UrlParameter.Optional
}
);