views:

99

answers:

5

Why is this:

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

preferred over this?

http://MySite.com/Project/24?Search=32&Edit=49
+3  A: 

Not really a fair comparison. The style allows you to drop the GET parameter names, so the routed one should read something like

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

It's really an aesthetic improvement, though -- it's both neater-looking, and easier to type or read out to someone.

Steve Cooper
The only problem with this syntax is that it requires every parameter. If one of the parameters is omitted, the routing will get confused.
Robert Harvey
A: 

Easier to remember as well. It's easier for a user to remember /Employee/1 to get the information for employee #1 rather than understand a querystring. Not a reason to use it but I think its a small improvement.

Cody C
+3  A: 

Its mostly a human readability issue, although (since most search engine ranking algorithms are not publically disclosed), it is believed to have SEO value as well.

JoshJordan
+6  A: 

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.

Michael Hart
It's a real example. See http://stackoverflow.com/questions/1080415/custom-routing-rules-e-g-www-app-com-project-35-search-89-edit-89/1080467#1080467
Robert Harvey
Wow - you're right - in so much as someone does want to construct their URLs like that anyway! I really think the poster doesn't want to do that though - unless I really misunderstand the domain. I don't get why a search would have an id. Or why it would be part of a particular project. Or why you'd want to edit it. But I'm probably missing something. In any case, I think your second suggestion on that topic is probably what they're looking for.
Michael Hart
+1  A: 

In the example case, it may not be any better. But it's a Search Engine Optimization in general. Here are some SEO best practices -- from that article ...

Ideally, the URL structures should be static, and reveal what the page is about. A simple and clear URL structure is much easier for both search engine spiders and human beings.

JP Alioto