我无法弄清楚或理解如何使我的路由工作,因为我希望它能在我的项目中工作。
我在视图中有以下表格
@using (Html.BeginForm("Filter", "Aanbod", FormMethod.Get))
{
<div class="filterBarComponent">
<div class="dropdownContainer">
@Html.DropDownList("Merk", EnumHelper.GetSelectList(typeof(Merken)), "-- Kies Merk")
</div>
<div class="dropdownContainer">
@Html.DropDownList("Brandstof", EnumHelper.GetSelectList(typeof(Brandstoffen)), "-- Kies Brandstof")
</div>
</div>
<div class="filterBarComponent">
<div>
<label for="sliderPrijs">Maximum Prijs</label>
<input id="sliderPrijs" name="prijs"
type="range"
min="100" max="100000"
step="100" value="@ViewBag.prijs"
oninput="outputUpdatePrijs(value)"
class="slider">
<output for="sliderPrijs" id="prijs"></output>
</div>
<div>
<label for="sliderKm">Kilometer Stand</label>
<input id="sliderKm" name="km"
type="range"
min="0" max="500000"
step="10000" value="@ViewBag.km"
oninput="outputUpdateKilometers(value)"
class="slider">
<output for="SliderKm" id="kmStand"></output>
</div>
</div>
<div class="filterBarComponent">
<input type="submit" value="Zoeken" class="filterbutton"/>
</div>
}
表单会导致此控制器操作。
[Route("filter/{km}/{prijs}/{merk}/{brandstof}/{page}")]
[HttpGet]
public ActionResult Filter( int km, int prijs, Merken merk = Merken.AlleMerken, Brandstoffen brandstof = Brandstoffen.AlleBrandstoffen, int page = 0 )
{
....
}
我的网址始终是/filter?Merk=&Brandstof=&prijs=25000&km=250000
虽然我想实现这个/filter/10000/5600/2/1
使用表格时是否可以这样做?
如果是这样,怎么样?如果没有,我该怎么办?