I have a search forms with pages that return a calendar. In top I have some search criteria and it all works fine if it's only one value but not if it's a list. When I want to build the url for the next month in my model I have something like this :
public ActionResult GetUrl()
{
var action = GetBaseAction();
if (SelectedDivisions.Any()) action.AddRouteValue("SelectedDisions", SelectedDivisions.ToArray());
if (RoomId.HasValue) action.AddRouteValue("RoomId", RoomId.Value);
if (TeacherId.HasValue) action.AddRouteValue("TeacherId", TeacherId.Value);
if (Month.HasValue) action.AddRouteValue("Month", Month.Value);
if (Year.HasValue) action.AddRouteValue("Year", Year.Value);
if (Day.HasValue) action.AddRouteValue("Day", Day.Value);
return action;
}
Wich add the parameters to the next month URL :
http://afi.local/coursesession/calendar?Month=9&Year=2012&Day=18&ViewType=weekly
but since you can select more than one division, it's a list of checkbox so when I post my form, I get this URL :
The problem is that if I add 2 times the same keys it throw an exception and I don't know how to rebuild my URL with more than one division in the query string.
Thanks for the help!