Pass parameter to new MVC controller

Asked

Viewed 40 times

0

I need to pass parameter "01" of http://localhost:5934/Gestaodeservicos/Catalogo/Cadastro/01, to another controller.

namespace Intranet.Presentation.Areas.GestaoDeServicos.Controllers
{
    public class ServicoController : Controller    {

        public ActionResult Cadastro(int id)
        {

            return this.View(id);
        }
    }
}

I want my route set to return to next: http://localhost:5934/Gestaodeservicos/Servico/Cadastro/01/00

Where parameter "01" is the id that came from the Catalogo controller and parameter "00" is nothing more than a new "Service".

  • 1

    You can add [Route("Cadastro/{id}/{num}")] to his action

  • 2

    You can do as @Ricardopunctual indicated, but I have a question... Why do you want to do this?

  • 1

    @Brunosouza, can explain your scenario better?

  • @Leandroangelo I did as suggested. It is a linear navigation. Whenever I access an "Id child", I need to pass via Controller the "Id Father". As I will have 5 levels, in the fifth and final, I will have to pass the 4 parameters.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.