我正在使用 MVC3 并在调用 Get 方法时遇到问题。
当我从其他视图在剃刀中调用此代码时,它运行良好。它使用正确的当前值发送关键字、位置参数。
看法
@using (Html.BeginForm("ListSearch", "Job",FormMethod.Get,null))
{
<div id="searchBoxes">
<div id="keywordsSearchBox" >
<input id="keywords_search_small" type="text" tabindex="2" title="@Resources.What" name="keyword">
<div class="searchExplain_small">@Resources.KeywordSearchDesc</div>
</div>
<div id="locationSearchBox">
<input id="location_search_small" type="text" tabindex="3" title="@Resources.Where" name="location" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">
<div class="searchExplain_small">@Resources.LocationSearchDesc</div>
</div>
<div id="searchButtonBox_small">
<input id="btnSearch" type="submit" value="@Resources.Search" role="textbox" aria-autocomplete="list" aria-haspopup="true"/>
</div>
</div>
}
控制器
public ViewResult ListSearch(string keyword, string location,int page
=1) ....
但是,当我从同一个视图调用同一个 Get 方法时,MVC 不会更新关键字、位置参数。相反,它发送前一个关键字位置参数。
我在 home 和 listSearch 视图中使用相同的剃须刀代码。
示例 URL
Home Page => Call GET Method ListSearch (keyword=manager, location=Richmond)
http://localhost:4838/Home/Index =>
http://localhost:4838/Job/ListSearch?keyword=manager&location=Richmond
List Search Page => Call GET Method ListSearch (keyword=lawyer, location=Miami)
http://localhost:4838/Job/ListSearch?keyword=manager&location=Richmond =>
http://localhost:4838/Job/ListSearch?keyword=manager&location=Richmond
参数不变
知道如何解决吗?