I am writing an MVC3 application which will have to use URL rewriting in the form http: // [server] / [City] - [State] / [some term] /.
As I understand it, MVC3 contains a routing mechanism that uses {controler} / {action} / {id}, which is defined in the Global.asax file:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
Traditionally (in a non-MVC application), I would use some rewrite URL to decode the url, for example http://www.myserver.com/City-State/somesearch/ , to querystring parameters that look something like this:
http://www.myserver.com/city=City&state=State&query=somesearch
Keep in mind that this request will come from http://www.myserver.com/Home
Is it possible to do this without specifying a controller ... something like this:
routes.MapRoute(
"Results",
"{city}-{state}/{searchTerm}",
new { controller = "Results", action = "Search" }
);
... , ?
MVC3?
.