In my asp.net mvc page, I want to call a RedirectToAction(actionName, controllerName, values).
The values parameter is an object that contains all the nessecary values. Example
return RedirectToAction(redirectAction, redirectController,
new{ personId = foundId,
personEmail = foundEmail,
personHeigh = foundHeight});
This is all well, if none of those parameters is null or an empty string.
When that happens, System.Uri.EscapeDataString(String stringToEscape) throws a ArgumentNullException.
The problem is I don't know at compile time what parameters will be null. Also, I would prefer not to make an object for each possible combination of notnull values.
In my example there are only three params, but what if would have 10? The possible combinations grow exponentially.
Since it is not possible to add fields to an anon type, I cannot add the parameters one by one either.
How can I solve this issue?