Di seguito un esempio per elencare e recuperare i valori contenuti in una Form utilizzando Request.Form Collection in Asp.Net utilizzando la NameValueCollection Class :
Per poter utilizzare la NameValueCollection Class fare riferimento ai namespace:
using System.Collections;
using System.Collections.Specialized;
string form_vs, form_v1, form_v2; void Page_Load(Object sender, EventArgs e) { ... x = 0; foreach (string _Fctrl in Request.Form) { x += 1; form_vs += x.ToString() + " " + _Fctrl + ": "; if (x > 5) { form_vs += "<b>" + Request.Form[_Fctrl] + "<b>" ; } form_vs += "<br />"; } ...
Ricercare un valore specifico presente in una Form
foreach (string _Fctrl in Request.Form) { if ( _Fctrl.Contains("email") { form_vs += _Fctrl + ": " + "<b>" + Request.Form[_ctl] + "<b><br />" ; } }
Utilizzando NameValueCollection
// Read Request Form NameValueCollection nvcF = Request.Form; int x = 0; foreach (string _nvcf in nvcF) { x += 1; form_vs += x.ToString() + " " + _nvcf + ": "; if (x > 5) { form_vs += "<b>" + nvcF[_nvcf] + "</b>" ; } form_vs += "<br />"; }
Altro esempio
if (!string.IsNullOrEmpty(nvcF["ctl00$MainContent$ctl00$email"])) { form_v2 += nvcF["ctl00$MainContent$ctl00$email"]; }
Risultato

Request.Form Collection
Risorse: