0

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?

3
  • Just try changing to url: "{controller}/{action}/{id}/{month}" Commented Dec 24, 2022 at 16:36
  • @viveknuna for design purposes, order should be /{month}/{id}. I know that it should work, but I am sure something is missing here. Commented Dec 24, 2022 at 18:31
  • I have finally used attribute routing only for this action, This was how it worked: [Route("Menu/PreSeleccion/{month:int?}/{id:int?}")] Commented Dec 24, 2022 at 19:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.