ASP.NET MVC Beta 1 - URI Routing Syntax

I have looked at the website for a decent explanation of the routing syntax in ASP.NET MVC Beta 1, but I still cannot get it to work.

Please, can someone explain what I need to add to my Global.asax.cs file two supported URIs for my site:

www.mysite.com/map.aspx

(i.e. a site without any explicit parameters / actions to perform the default action) and

www.mysite.com/map.aspx/search/searchParam1/searchParam2/searchParam3/

(to perform a search)

PS: For now I will continue working on this and I will post the answer myself if I find it.

0


source to share


1 answer


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

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

      

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

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



Then you can parse the parameters to process the search results.

However, in my opinion, when installing an MVC app, placing the map.aspx in the url doesn't look right. Your url should look like http://www.mysite.com/search/

+2


source







All Articles