i have a quetion about MVC routing.
I have a controller method that is called with many different combinations of URL's. To overcome issue i am using optional parameters.
here is my controller method signature...
public ActionResult localMembersSearch(string Gender, string calling, [Optional]string Region, [Optional]string County, [Optional]string Town, [Optional]string queryvalues)
the first two parameters are not optional but always expected.
here is my URL route..
routes.MapRoute(
"memberDataSort",
"MemberSearch/UKMembers/{Gender}/{Calling}/options/{*queryvalues}",
new { controller = "MemberSearch", action = "localMembersSearch", Gender = "", Calling = "", Region = "", County = "", Town = "", queryvalues = "" }
);
now what i would like is to be able to say that the string where {*queryvalues} is placed is set to the parameter 'queryvalues'.
as wha开发者_如何学Cts happening at the moment is the controller is getting called with "Gender", "Calling" and "Region".
is there a way in the Route i can explicity say, fill the 'queryvalues' parameter with {*queryvalues} ?
so the controller would recieve the signature below...
localMembersSearch("Gender", "Calling", "", "", "", "queryvalues")
any help is most apreciated ;)
Truegilly
just though about this and realized this obvious solution...
localMembersSearch("Gender", "Calling", "null", "null", "null", "queryvalues")
my controller method checks for relevant region, county, town data and so this works ok
truegilly
精彩评论