I need to pass an array of values in Url.Action
.
Currently I'm doing:
var redirectUrl = Url.Action("search", new {
q = criteria.Q,
advanced = criteria.Advanced,
salaryfrom = criteria.SalaryFrom,
salaryto = criteria.SalaryTo,
});
if (criteria.JobTypes != null)
redirectUrl += criteria.JobTypes.Aggregate(string.Empty, (a, x) => a += "&jobTypes=" + x);
To give me something like:
/search?q=developer&advanced=false&salaryfrom=20000&salaryto=80000&jobTypes=Full%20Time&jobTypes=Contract
Is there a nicer/cleaner approach?