views:

416

answers:

1

I have scoured the web for a decent explanation of the routing syntax in ASP.NET MVC Beta 1 but I still can't get it to work.

Please could someone explain what I need to put in my Global.asax.cs file to have two supported URIs for my site:

www.mysite.com/map.aspx (i.e the site without any explicit parameters/actions for performing the default action), and,

www.mysite.com/map.aspx/search/searchParam1/searchParam2/searchParam3/ (for performing a search)

PS: In the meantime, I'll continue working on this and I'll post the answer myself if I find it.

+2  A: 
routes.MapRoute("Default", "map.aspx", new { controller = "DefaultController", action = "DefaultAction" });

routes.MapRoute("Search", "map.aspx/search/{*params}", new { controller = "SearchController", action = "Search" } );

Example URL : http://www.mysite.com/map.aspx/search/dogs/cats/

Parameters passed to SearchController.Search() : params="/dogs/cats"

You can then parse the params in order to process your search results.

However, in my opinion, putting map.aspx in the URL looks wrong if you are building an MVC application. Your url should look like http://www.mysite.com/search/

Franck
Thanks sork. The map is a specific subsection of the site and so (unless I'm mistaken) needs to be in there to differentiate from the rest of the website's functionality. The aspx is because (obviously) the site is on IIS6.Thanks again.
Ben Aston