ASP.NET MVC Html.BeginRouteForm不调用action方法

时间:2018-04-23 09:26:08

标签: c# asp.net-mvc routes

我在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 &raquo;" 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中定义的相同。

这样做的正确方法是什么?

0 个答案:

没有答案