views:

130

answers:

2

What would be the most appropriate route for this URL?

www.mysite.com/searchkey0

www.mysite.com/searchkey1

Where searchkey is the keyword for a search method? I tried the following route:

routes.MapRoute( _
        "SearchRoute", _
        "search", _
        New With {.controller = "Search", .action = "Search", .id = ""} _
   )

In this route, the URL must have /search/searchkey. I only want to have the searchkey in the URL, and not the word Search.

What am I missing?

+5  A: 

Try this:

routes.MapRoute( _
        "SearchRoute", _
        "{id}", _
        New With {.controller = "Search", .action = "Search", .id = ""} _
   )
Robert Harvey
thanks, i will try it and will post back if it working :)
mcxiand
its working now. thank you very much Robert.
mcxiand
+1  A: 

to see what route your mvc is using have alook at this tool

http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx

hth

bones

dbones
thanks, that is useful
mcxiand