How do you construct your routes?

After much thought, and perusal of samples, it came to me that I may be thinking about my route construction wrong. While I was learning mvc, all the “basic” sample used the following style:

{controller}/{action}/{id}

And this is how I’ve been thinking about it ever since. This works for the data model driven app, but seems to break down when using a domain model driven app. An example would be in a catalog style application that has the following aggregate chain:

Author -> Book -> Chapter

If one was to have the following controller, using the data driven model, things work:

ChapterController.Edit(id)

And then fetch, update, and commit the exact chapter needed.

But in a domain model, the topmost repository is for Author. You’d have to call the following to get the chapter.

Author author = authorRepository.GetByName(authorName);
Book book = author.LocateBookByName(bookName);
Chapter chapter = book.LocateChapterByName(chapterName);

Then perform your updates and commits. This would seem to want a route and handler more like:

Chapter/Edit/{authorName}/{bookName}/{chapterName}

ChapterController.Edit(string authorName, string bookName, string chapterName);

But even that doesn’t look entirely correct.

So the question is: how would YOU construct this route and handler?

This might expand my understanding greatly.

Thanks in advance for any replies.

In general, our admin interfaces live in a separate application from our public stuff, and no one really cares what urls look like on the back-end. So the edit scenario would probably be a more typical {controller}/{action}/{id} wheras the front-end ends up as pretty as we need it to be.

This wouldn’t be an admin interface though. Let me expand on this by using my forum application.

The Forum entity contains two lists: one is for sub Forums, the other for thread (Post entities). The Post entity also contains a list of replies (more Post entities).

So let’s say I have a top level forum titled “General Information” and a subforum in that titled “Outdated Information”. In this subforum, I made a post announcing something, and somebody replied to it with a question, and I replied clarifying something. We now have a Forum - Forum - Post - Post (reply) - Post (reply) scenario. Each entity being owned by the previous.

If I were to edit my reply, what should the url look like? The easiest of course is Post/Edit/42, where 42 is the post id. But this doesn’t follow DDD rules. For this to work, I’d need to have a PostRepository, and we all know that according to the aggregate chain, the only repository I should have is ForumRepository. But in this case, I would need an url that was dynamic enough to accomodate any level of nested forums and posts.

Advice?