views:

186

answers:

6

Hi all, I am curious if is out-of-date to use query string for id. We have webapp running on Net 2.0. When we display detail of something (can be product) we use query string like this : http://www.somesite.com/Shop/Product/Detail.aspx?ProductId=100

We use query string for reason that user can save the link somewhere and come back any time later. I suppose that we use url rewriting soon or later but in mean time I would like to know your opinion. Thanks.Cheers, X.

+2  A: 

Nothing wrong with query string parameters. Simple to create and understand. A lot of sites are using fancy urls like 'www.somesite.com/Shop/Product/white_sox_t_shirt` which is cool and sort-of user friendly, but more work for us poor developers.

Ray
A: 

Permanent links are best for SEO and also , what if your product moved to another database , and the ID of the product needs to be changed ?
I don't think the chances of a product's name will be changed or the manufacturer. E.g Apple/Iphone won't change :) Seems to me a good Permalink

Bahadir Cambel
There's nothing non-permanent about using query strings, and why would moving databases require the ids to be changed? Preserving old ids is easy.
David Dorward
Well I think that using names has sense, but we also have other language mutations, like chinese. Then it wont work. So, id fits to us and yes, I dont see problem with migration.
Xabatcha
david , what if you want to merge different database ? I mean these are possibilities. Because of this reason, lots of companies uses GUID rather than Ids.Xabatcha - You can write down your product name in Chinese.As I said in my first sentence , best for SEO. I don't mind if you use both and I never disagree about using the ID in the QS.
Bahadir Cambel
+3  A: 

Using query strings is not outdated at all, it just has to be used in the right places. However, never place anything in the query string that could be a security issue and remember that anything you read from the query string could have been modified so you should be validating all input in your checks.

keyboardP
I think this TheDailyWTF article is relevant here: http://thedailywtf.com/comments/The_Spider_of_Doom.aspx
DrJokepu
lol, that's brilliant (from a humorous POV - not so much from a security POV!). Management's reaction sounds quite standard...
keyboardP
That is one of mine concern too. The security, as all the query strings must be strongly checked. But you need to do this with restfull approach either. So, there is no really diff.
Xabatcha
+4  A: 

A common strategy is to use an item ID in the URL, coupled with some keywords that describe the item. This is good from a user's perspective, because they can easily see what a URL refers to if they save it somewhere. More importantly, it's useful from a SEO (Search Engine Optimisation) point of view, as search engines will - it is said - rate a given URL more highly if it contains the keywords someone is searching for.

You can see this approach on this very site, where the ID after 'questions' is used for the database query and the text is purely for the benefit of users and search engines.

Whether you use a straightforward query string, or a more advanced approach that makes the ID look like part of the folder path, is up to you. It's largely a matter of personal taste.

Dogmang
+1  A: 

It's not outdated, but anothter alternative is a more RESTful approach:

yourwebsite.com/products/100/usb-coffee-maker

The reason is that a) search engines usually ignore any URL with a QueryString (so the product.aspx?id=100 page may never get indexed) and b) having the name in the url purely for display purposes supposedly helps SEO as well.

Michael Stum
Search engines do not ignore URLs with query strings (they tend to ignore URLs with many-parted query strings. A one part ID isn't a problem).
David Dorward
@David: Depends on the Spider. Googlebot does allow a limited number, others may not and refuse to even use one. Arguably only Google is important in the western world, but still something to keep in mind.
Michael Stum
+1 for the URL example, which is the industry standard and a clear, intuitive approach.
grenade
+3  A: 

Yes, it is old fashioned!

However, if you are thinking about changing it to a RESTful implementation as others have suggested, then you should continue to support the old URL and querystring addresses by implementing an HTTP 301 redirect to forward from the querystring URLs, to the new restful URLs. This will ensure that any users old links and bookmarks will continue to work while telling the search engine bots that the url has changed.

Since your post is tagged ASP.Net, there is a good write-up on how you can support both, using the new ASP.Net routing mechanism here: http://msdn.microsoft.com/en-us/magazine/dd347546.aspx

grenade