1
In my view I have two buttons that pass parameters via GET to my controller index, the problem is that the URL does not stick to the traditional ? id=1 and I wanted to make it look like this: /controller/1
View:
@using (Html.BeginForm(FormMethod.Get))
{
<button type="submit" class="btn btn-primary" value="1" name="id">sites1</button>
<button type="submit" class="btn btn-primary" value="2" name="id">sites2</button><br />
}
Controller:
public async Task<IActionResult> Index(int? id)
{
var listaDeSites = await _listaService.ListaDeSitesAsync(id);
return View(listaDeSites);
}
Could you post your Routeconfig class code? Thank you.
– Pedro Paulo
Ta in the default Asp.net core app.Usemvc(Routes => { Routes.Maproute( name: "default", template: "{controller=Home}/{action=Index}/{id? }"); });
– Márcio Sebastião
ps.: Do you mean
/Controller/1
,/Controller/Action/1
or./Action/1
?– Leandro Angelo