jstuardo
jstuardo

Reputation: 4373

Routing cannot map action parameters correctly

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?

Upvotes: 0

Views: 21

Answers (0)

Related Questions