mark vanzuela
mark vanzuela

Reputation: 1391

ASP.NET MVC Routing

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?

Upvotes: 4

Views: 369

Answers (2)

dbones
dbones

Reputation: 4504

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

Upvotes: 1

Robert Harvey
Robert Harvey

Reputation: 180918

Try this:

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

Upvotes: 5

Related Questions