I have a project in ASP.NET Core 5, what I need is quite simple. I want to indicate in the id value a default int value in routing. However, when I trace the controller, it always returns the id as 0 or null.
public IActionResult Seccion(int id)
{
return View();
}
this is my Start.up file
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=podcast}/{action=Index}/{id?}");
endpoints.MapControllerRoute(
name: "historias",
pattern: "seccion/{id=300}",
defaults: new { controller = "Podcast", action = "Seccion" });
});
As you can see, I expect when the https://localhost:xxx/podcast/seccion/historias is entered the Seccion() action method is called with id set to 300 by default. But the id always arrives 0.
