1
I am running the Action below, but the parameter "Artigooucategoria" is not being passed to the Controller. I am working with Asp.net core 2.0.
public async Task<IActionResult> Buscar(string ArtigoOuCategoria)
{
...
}
The Action call is below:
<div class="card mb-4">
<div class="card-body">
<h4 class="card-title">Categorias</h4>
@foreach (var item in Model.Categorias)
{
<a class="btn btn-light btn-sm mb-1" asp-controller="Artigo" asp-action="Buscar/@item.Descricao">@item.Descricao</a>
}
</div>
</div>
The Action call was also made as follows:
<a href="Artigo/Buscar/@item.Descricao">@item.Descricao</a>
Includes the route instructions in the project’s startup.Cs file:
routes.MapRoute(
name: "buscar",
template: "Artigo/Buscar/{ArtigoOuCategoria?}",
defaults: new { controller = "Artigo", action = "Buscar" });
Your route is set before of the standard route?
– Marcelo Shiniti Uchimura
Not this one, I tried to change the order to see if there would be any difference, but I noticed that.
– Gleison França
ArtigoOuCategoria
is typed on your route?– Marcelo Shiniti Uchimura
No.. the parameter is string type but I did not specify its type on the route
– Gleison França