Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Why is this:

http://MySite.com/Project/24/Search/32/Edit/49

preferred over this?

http://MySite.com/Project/24?Search=32&Edit=49
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
163 views
Welcome To Ask or Share your Answers For Others

1 Answer

I'm not sure where your premise is coming from? It looks like an artificial example, which makes it hard to comment on.

A better comparison would be something like:

http://MySite.com/Project/24/Members/Edit

As opposed to:

http://MySite.com/Projects.aspx?id=24&section=Members&action=Edit

Where, among other things, the hierarchy of entities is immediately obvious from the first example (ie, a Project contains Members). It also suggests that you can use other URLs that contain similar structures to the first (ie, /Projects/24 and /Projects/24/Members), so in that sense it's more concise.

If it comes down to actions that have a variable number of parameters, such as searching, then it's totally fine to use URL parameters as this will give you more flexibility, eg:

http://MySite.com/Projects/Search?name=KillerApp&type=NET

You could construct a URL using the first style, but you don't really gain anything, and managing the route could add unnecessary overhead:

http://MySite.com/Projects/Search/name/KillerApp/type/NET

I would argue that this (or any similar construction, eg if you removed the param names) suffers from an artificial hierarchy - the action in this case is really Search, and everything else is just a parameter of the Search, so it's in the same hierarchy, not some "sub" hierarchy.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...