Sorry if this question has already been asked and answered, but I couldn't seem to hit a search term that gave me an answer.
I have an MVC5 project and I want to use a url like http://localhost/Controller/1/ChildController/Edit/1 to access the child record(s) of a parent record.
Is this possible? It seems like a custom Route or Attribute Routing might be the solution but I cant quite see how I would implement it.
EDIT
I have created a controller method like this
[Route("Supervision/{id:int}/Session/Edit/{sessionId:int}")]
public ActionResult SessionEdit(int id, int sessionId)
{
return View();
}
Which seems to work as I wanted, so now my question is, is this approach OK? Does it break any best practice or standards?
Which seems to work as I wanted, so now my question is, is this approach OK? Does it break any best practice or standards?
Yes, it is ok and does not break any best practice standards. You have left no room for ambiguity with this route, which is great.