FormReader Class

Used to read an ‘application/x-www-form-urlencoded’ form.

Namespace
Microsoft.AspNetCore.WebUtilities
Assemblies
  • Microsoft.AspNetCore.WebUtilities

Syntax

public class FormReader : IDisposable
class Microsoft.AspNetCore.WebUtilities.FormReader

Constructors

FormReader(System.IO.Stream)
public FormReader(Stream stream)
FormReader(System.IO.Stream, System.Text.Encoding)
public FormReader(Stream stream, Encoding encoding)
FormReader(System.IO.Stream, System.Text.Encoding, System.Buffers.ArrayPool<System.Char>)
public FormReader(Stream stream, Encoding encoding, ArrayPool<char> charPool)
FormReader(System.String)
public FormReader(string data)
FormReader(System.String, System.Buffers.ArrayPool<System.Char>)
public FormReader(string data, ArrayPool<char> charPool)

Methods

Dispose()
public void Dispose()
ReadForm()

Parses text from an HTTP form body.

Return type:System.Collections.Generic.Dictionary<System.String>
Returns:The collection containing the parsed HTTP form body.
public Dictionary<string, StringValues> ReadForm()
ReadFormAsync(System.Threading.CancellationToken)

Parses an HTTP form body.

Arguments:cancellationToken (System.Threading.CancellationToken) – The System.Threading.CancellationToken.
Return type:System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<System.String>>
Returns:The collection containing the parsed HTTP form body.
public Task<Dictionary<string, StringValues>> ReadFormAsync(CancellationToken cancellationToken = null)
ReadNextPair()

Reads the next key value pair from the form. For unbuffered data use the async overload instead.

Return type:System.Nullable<System.Collections.Generic.KeyValuePair<System.String>>
Returns:The next key value pair, or null when the end of the form is reached.
public KeyValuePair<string, string>? ReadNextPair()
ReadNextPairAsync(System.Threading.CancellationToken)

Asynchronously reads the next key value pair from the form.

Return type:System.Threading.Tasks.Task<System.Nullable<System.Collections.Generic.KeyValuePair<System.String>>>
Returns:The next key value pair, or null when the end of the form is reached.
public Task<KeyValuePair<string, string>? > ReadNextPairAsync(CancellationToken cancellationToken = null)

Fields

DefaultKeyLengthLimit()
Return type:System.Int32
public const int DefaultKeyLengthLimit = 2048
DefaultValueCountLimit()
Return type:System.Int32
public const int DefaultValueCountLimit = 1024
DefaultValueLengthLimit()
Return type:System.Int32
public const int DefaultValueLengthLimit = 4194304

Properties

Microsoft.AspNetCore.WebUtilities.FormReader.KeyLengthLimit

The limit on the length of form keys.

Return type:System.Int32
public int KeyLengthLimit { get; set; }
Microsoft.AspNetCore.WebUtilities.FormReader.ValueCountLimit

The limit on the number of form values to allow in ReadForm or ReadFormAsync.

Return type:System.Int32
public int ValueCountLimit { get; set; }
Microsoft.AspNetCore.WebUtilities.FormReader.ValueLengthLimit

The limit on the length of form values.

Return type:System.Int32
public int ValueLengthLimit { get; set; }