views:

28

answers:

2

HI All, I got a question about the URL Routing feature in .Net 4.0

My URL the I want to rewrite is : www.mysite.com/counties.aspx?id=12 I could make it work like that : www.mysite.com/12/egypt

But I want it to work without passing the id of the country in the query to look like this www.mysite.com/egypt

So ,I want to know how can I pass that parameter without showing it in the url.Another approach I thought about is to select the record using the country name instead of id and remove any spaces that could appear in country names. But I don’t like it, and I would like to make it work with the id.

Anyone can help?

A: 

Hey,

You would need to use Session, cache, or something like that; or pass egypt, and do a database lookup to get the 12 value back from the reference table.

HTH.

Brian
Thanks Brian for reply,i think session isn't good for search engines,i think rather than the lookup i would make the country name my select parameter.
Khaled
+1  A: 

I had this problem before. I added a ShortUrl field to the Country table. Then passed that in as the querystring. www.mysite.com/counties.aspx?shortUrl=egypt. This way your url can look like this :www.mysite.com/egypt. Of course you need to change your query to get the the country based on the shortUrl rather than the id.

James Lawruk
Thanks James,i will do the same,may be i will create an index on that ShortUrl column to optimize the query performance.
Khaled
Hi Khaled, Thanks for the response. With less than 200 countries in the world, a full table scan should perform just fine, so the index may not make much difference.
James Lawruk
I agree James,but the country was just and example :),Thanx
Khaled