Pattern to iterate Request Params
- by NOOBie
My view is not a strongly typed view and I need to iterate through Request Params in the controller action to determine the values posted.
Is there a better way to iterate through the nameValueCollection AllKeys?
I am currently looping through the Request Params and setting values appropriately.
foreach (var key in Request.Params.AllKeys)
{
if (key.Equals("CustomerId"))
queryObject.CustomerId = Request.Params[key];
else if (key.Equals("OrderId"))
queryObject.OrderId= Request.Params[key];
//and so on
}
I see a considerable amount of repetition in this code. Is there a better way to handle this?