Hi All,
I have a .net mvc with the following routes:
routes.Add(new Route(
"Lookups/{searchtype}/{inputtype}/{firstname}/{middlename}/{lastname}/{city}/{state}/{address}",
new RouteValueDictionary( new { controller = "Lookups", action = "Search", firstname = (string)null, middlename = (string)null, lastname = (string)null, city = (string)null, state = (string)null, address = (string)null, SearchType = SearchType.PeopleSearch, InputType = InputType.Name }),
new MvcRouteHandler())
);
routes.Add(new Route(
"Lookups/{searchtype}/{inputtype}",
new RouteValueDictionary( new { controller = "Lookups", action = "Search", firstname = "", middlename = "", lastname = "", city = "", state = "", address = "" }),
new MvcRouteHandler())
);
routes.Add(new Route(
"Lookups/{searchtype}/{inputtype}",
new RouteValueDictionary( new { controller = "Lookups", action = "Search", firstname = "", middlename = "", lastname = "", city = "", state = "", address = "", SearchType = SearchType.PeopleSearch, InputType = InputType.Name }),
new MvcRouteHandler())
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Account", action = "LogOn", id = "" } // Parameter defaults
);
The following request works fine:
http://localhost:2608/Lookups/PeopleSearch/Name/john/w/smith/seattle/wa/123 main
This request does not work:
http://localhost:2608/Lookups/PeopleSearch/Name/john//smith//wa/
Not all requests will have all paramters and I would like empty parameters to be passed to the method as empty string or null.
Where am I going wrong?
The method:
public ActionResult Search(string firstname, string middlename, string lastname, string city, string state, string address, SearchType searchtype, InputType inputtype)
{
SearchRequest r = new SearchRequest { Firstname = firstname, Middlename = middlename, Lastname = lastname, City = city, State = state, Address = address, SearchType = searchtype, InputType = inputtype };
return View(r);
}