Routing cannot map action parameters correctly

22 views Asked by At

I have this in RouteConfig.cs file:

        routes.MapRoute(
            name: "PreSeleccion",
            url: "{controller}/{action}/{month}/{id}",
            defaults: new { controller = "Menu", action = "PreSeleccion" }
        );

On the other hand, I have this in the Menu controller:

    // GET: Menu/PreSeleccion/{month}/{id}
    [HttpGet]
    [AllowAnonymous]
    public async Task<ActionResult> PreSeleccion(int month = 0, int id = 0)
    {

    }

When calling that action with this URL: /Menu/PreSeleccion/202301/80 and debug, I can see that month parameter is 0 and the id parameter is 202301.

How can I fix this?

0

There are 0 answers