I am having trouble figuring out or understanding how to make my routing work as i would like it to work in my project.
I have the following form in a view
@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>
}
The form leads to this controller action.
[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 )
{
....
}
My Url is always /filter?Merk=&Brandstof=&prijs=25000&km=250000
While i want to achieve this /filter/10000/5600/2/1
Is it possible to do this while using forms?
If so, how? if not, what should i do as alternative?