IFormCollection.Item[String] Property

Definition

Gets the value with the specified key.

public:
 property Microsoft::Extensions::Primitives::StringValues default[System::String ^] { Microsoft::Extensions::Primitives::StringValues get(System::String ^ key); };
public Microsoft.Extensions.Primitives.StringValues this[string key] { get; }
member this.Item(string) : Microsoft.Extensions.Primitives.StringValues
Default Public ReadOnly Property Item(key As String) As StringValues

Parameters

key
String

The key of the value to get.

Property Value

The element with the specified key, or StringValues.Empty if the key is not present.

Exceptions

key is null.

incorrect content-type.

Remarks

IFormCollection has a different indexer contract than IDictionary<TKey,TValue>, as it will return StringValues.Empty for missing entries rather than throwing an Exception.

This indexer can only be used on POST requests. Otherwise an exception of type InvalidOperationException is thrown.

Invoking this property could result in thread exhaustion since it's wrapping an asynchronous implementation. The HttpRequest.ReadFormAsync(CancellationToken) method can get the form without blocking. For more information, see https://aka.ms/aspnet/forms-async.

Applies to