【发布时间】:2013-02-27 09:30:16
【问题描述】:
有谁知道如何解决这个问题,我有一个搜索框,当我输入搜索短语并提交表单时,网址是:
http://localhost:50435/Search-Results-For?q=hotels&Option=Web&Page=1
返回结果后,我就可以分页了,url是:
http://localhost:50435/Search-Results-For/hotels/web/2
但如果我随后尝试进行另一次搜索,则该搜索会附加到上面的 url:
http://localhost:50435/Search-Results-For/hotels/web/2?q=poole&Option=web&Page=2
我不知道如何解决这个问题,我尝试将寻呼机放在部分视图中,更改参数但似乎没有任何效果。
以前有没有人遇到过这个问题或知道如何解决。
寻呼机:
<div id="dvPagePager">@Html.PagedListPager((IPagedList)ViewBag.SearchResults, page => Url.Action("Results", new { Page = page, q = @ViewBag.q, Option = @ViewBag.b}), PagedListRenderOptions.OnlyShowFivePagesAtATime)</div>
表格:
@using (Html.BeginRouteForm("SearchEngine", FormMethod.Get, new { @id = "frmSearchEngine" }))
{
{ Html.RenderAction("pvSearchForm", "Home"); }
//Html.RenderPartial("~/Views/Shared/pvSearchForm.cshtml");
}
路线:
routes.MapRoute(
name: "SearchEngine",
url: "Search-Results-For/{q}/{Option}/{Page}",
defaults: new { controller = "Search", action = "Results", q = UrlParameter.Optional, Option = UrlParameter.Optional, Page = UrlParameter.Optional }
);
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-4 asp.net-mvc-routing