I was wondering what is the best way to go about routing? I have a Index method like:
public IActionResult Index(int parentId = -1, int page = 0){
...
return(model);
}
so since this action has default values, I would like the user be able to get to this action using controller
, contoller/index
, controller/parent/{parentId}
, controller/page/{page}
, controller/{parentId}/page/{page}
.
there are still more variations with [action] in the beginning which I have omitted.
so I have to make these routes (give or take) :
[Route("[action]/department/{parentId:int}/page/{page=0?int}")]
[Route("department/{parentId:int}/page/{page=0?int}")]
[Route("[action]/page/{page=0?int}")]
[Route("page/{page=0?int}")]
[Route("[action]")]
[Route("")]
And I was thinking if I get to have more parameters, this list could go a lot longer.
I feel there is something that I'm missing because this approach doesn't feel right.
I would like ask you to point me to a better direction. thanks