public ActionResult SubmitForm(FormCollection form) { string[] values = form.GetValues("myFieldName"); // do something with values }
public ActionResult SubmitForm(FormCollection form) { foreach (string fieldName in form.AllKeys) { string[] values = form.GetValues(fieldName); // do something with values } }This example shows how to use the FormCollection class to retrieve multiple values for multiple form fields. The AllKeys property returns an array of string values representing all of the submitted form field names, which are then used to retrieve the corresponding form field values using the GetValues method. Package library: `System.Web.Mvc` is part of the ASP.NET MVC framework.