How Do I get City State Zip in MVC 3 URL Route without writing a controller for every state and actions for each city
- by OpTech Marketing
I have the need to have the urls in my bosses application look like:
http://domain.com/Texas/Dallas/72701
However, I don't want to write a controller for every state and an action for every city.
routes.MapRoute(
"DrillDown", // Route name
"{controller}/{action}/{ZipId}",
new { controller = "State", action = "City", ZipId = UrlParameter.Optional} // Parameter defaults
Can someone help me write a pattern for the routes that will accept State/City/Zip without destroying the ability for me to have regular routes with controller/Action/Param ?
Looking all over and can't find any direction.