Action Method 的签名如下所示:
public ActionResult DwellingAdvertsByCity(
string cityName,
int numberOfResultsPerPage,
int pageIndex)
我的 Razor 表单如下所示:
@using (Html.BeginForm(
"DwellingAdvertsByCity",
"DwellingAdvert",
new { controller = "DwellingAdvert", action = "DwellingAdvertsByCity" },
FormMethod.Get
))
{
@Html.DropDownList("CityName")
<p>
<input type="hidden" name="numberOfResultsPerPage" id="numberOfResultsPerPage" value="3" />
<input type="hidden" name="pageIndex" id="pageIndex" value="1" />
<input type="submit" value="Submit" />
</p>
}
提交我的“NewYork”选择后,我会在以下 URL 下看到结果列表:
http://localhost:XXX/DwellingAdvert/DwellingAdvertsByCity?CityName=NewYork&numberOfResultsPerPage=3&pageIndex=1
任何想法如何从基本配置更改路由配置:
routes.MapRoute(null, "{controller}/{action}");
要匹配,我会在以下 URL 下看到结果列表:
http://localhost:XXX/NewYork
?
我花了几个小时试图弄清楚,没有结果,所以我问你们。
关于问题的任何建议?