Doubt with decorator [Route ("")]

1

I have the following controller

[Route("micontrolador")]
public class MiController : Controller
{
    [Route("micontrolador/miaccion")]
    public ActionResult Index() => View();
}

path micontrolador / miaccion

Is it necessary to indicate in the controller the path of this or just enough to add the [Route] to the methods of the controllers?

To make it look like this

public class MiController : Controller
{
    [Route("micontrolador/miaccion")]
    public ActionResult Index() => View();
}

path micontrolador / miaccion

    
asked by vcasas 12.06.2018 в 22:23
source

1 answer

2

According to this article , it is correct to define the routes directly in the method, without having to repeat them in the controller.

Your second option should then work:

public class MiController : Controller
{
    [Route("micontrolador/miaccion")]
    public ActionResult Index() => View();
}
    
answered by 12.06.2018 / 22:30
source