public ActionResult ProcessForm(FormCollection form) { string username = form["username"]; // do something with username }
public ActionResult ProcessForm(FormCollection form) { string[] selectedFruits = form.GetValues("fruit"); // do something with selectedFruits }In this example, all form elements with the name "fruit" are extracted and stored in an array. The System.Web.Mvc FormCollection class is part of the System.Web.Mvc package library.