HttpRequest.Form Property

Definition

Gets a collection of form variables.

C#
public System.Collections.Specialized.NameValueCollection Form { get; }

Property Value

A NameValueCollection representing a collection of form variables.

Examples

The following example shows how to read the values in the form collection posted from a browser. Each name/value pair in the collection represents a control in the form and its value.

C#
int loop1;
NameValueCollection coll;

//Load Form variables into NameValueCollection variable.
coll=Request.Form;
// Get names of all forms into a string array.
String[] arr1 = coll.AllKeys;
for (loop1 = 0; loop1 < arr1.Length; loop1++)
{
   Response.Write("Form: " + arr1[loop1] + "<br>");
}

Remarks

The Form property is populated when the HTTP request Content-Type value is either "application/x-www-form-urlencoded" or "multipart/form-data".

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also