FormCollection Class

Contains the parsed form values.

Namespace
Microsoft.AspNetCore.Http
Assemblies
  • Microsoft.AspNetCore.Http

Syntax

public class FormCollection : IFormCollection, IEnumerable<KeyValuePair<string, StringValues>>, IEnumerable
class Microsoft.AspNetCore.Http.FormCollection

Constructors

FormCollection(System.Collections.Generic.Dictionary<System.String, Microsoft.Extensions.Primitives.StringValues>, Microsoft.AspNetCore.Http.IFormFileCollection)
public FormCollection(Dictionary<string, StringValues> fields, IFormFileCollection files = null)

Methods

ContainsKey(System.String)

Determines whether the Microsoft.AspNetCore.Http.HeaderDictionary contains a specific key.

Arguments:key (System.String) – The key.
Return type:System.Boolean
Returns:true if the Microsoft.AspNetCore.Http.HeaderDictionary contains a specific key; otherwise, false.
public bool ContainsKey(string key)
GetEnumerator()

Returns an struct enumerator that iterates through a collection without boxing and is also used via the Microsoft.AspNetCore.Http.IFormCollection interface.

Return type:Microsoft.AspNetCore.Http.FormCollection.Enumerator
Returns:An Microsoft.AspNetCore.Http.FormCollection.Enumerator object that can be used to iterate through the collection.
public FormCollection.Enumerator GetEnumerator()
GetEnumerator()

Returns an enumerator that iterates through a collection, boxes in non-empty path.

Return type:System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<System.String>>
Returns:An System.Collections.IEnumerator object that can be used to iterate through the collection.
IEnumerator<KeyValuePair<string, StringValues>> IEnumerable<KeyValuePair<string, StringValues>>.GetEnumerator()
GetEnumerator()

Returns an enumerator that iterates through a collection, boxes in non-empty path.

Return type:System.Collections.IEnumerator
Returns:An System.Collections.IEnumerator object that can be used to iterate through the collection.
IEnumerator IEnumerable.GetEnumerator()
TryGetValue(System.String, out Microsoft.Extensions.Primitives.StringValues)

Retrieves a value from the dictionary.

Arguments:
Return type:

System.Boolean

Returns:

true if the Microsoft.AspNetCore.Http.HeaderDictionary contains the key; otherwise, false.

public bool TryGetValue(string key, out StringValues value)

Fields

Empty()
Return type:Microsoft.AspNetCore.Http.FormCollection
public static readonly FormCollection Empty

Properties

Microsoft.AspNetCore.Http.FormCollection.Count

Gets the number of elements contained in the Microsoft.AspNetCore.Http.HeaderDictionary;.

Return type:System.Int32
Returns:The number of elements contained in the Microsoft.AspNetCore.Http.HeaderDictionary.
public int Count { get; }
Microsoft.AspNetCore.Http.FormCollection.Files
Return type:Microsoft.AspNetCore.Http.IFormFileCollection
public IFormFileCollection Files { get; }
Microsoft.AspNetCore.Http.FormCollection.Item[System.String]

Get or sets the associated value from the collection as a single string.

Arguments:key (System.String) – The header name.
Return type:Microsoft.Extensions.Primitives.StringValues
Returns:the associated value from the collection as a StringValues or StringValues.Empty if the key is not present.
public StringValues this[string key] { get; }
Microsoft.AspNetCore.Http.FormCollection.Keys
Return type:System.Collections.Generic.ICollection<System.String>
public ICollection<string> Keys { get; }