我在RouteConfig.cs中定义了以下路线:
routes.MapRoute(
name: "VehicleAdvancedSearchResult",
url: "search-result/{SearchTypeSlug}/{Condition}/{MakeSlug}/{ModelName}/{ModelExt}/{CategorySlug}/{ParishSlug}/{YearRange}/{PriceRange}",
defaults: new
{
controller = "SearchResult",
action = "VehicleAdvanceSearch",
searchTypeSlug = UrlParameter.Optional,
cond = UrlParameter.Optional,
makeSlug = UrlParameter.Optional,
model = UrlParameter.Optional,
modelExt = UrlParameter.Optional,
cat = UrlParameter.Optional,
parishSlug = UrlParameter.Optional,
yearRange = UrlParameter.Optional,
priceRange = UrlParameter.Optional
}
);
在局部视图中我有这个:
<% using (Html.BeginRouteForm("VehicleAdvancedSearchResult", new { controller = "SearchResult", action = "VehicleAdvanceSearch" })) {
...
<input type="submit" value="Search »" class="btn btn-clc-theme-green medium white-text" />
<%}%>
以下是控制器方法:
public ActionResult VehicleAdvanceSearch(
string SearchTypeSlug,
string Condition,
string MakeSlug,
string ModelName,
string ModelExt,
string ParishSlug,
string CategorySlug,
string YearRange,
string PriceRange,
string pages)
{
// Code here...
}
我希望在单击“提交”按钮时调用上述方法,但事实并非如此。单击按钮后,我希望URL
的准备工作与RouteConfig.cs
中定义的相同。
这样做的正确方法是什么?