WebHeaderCollection.AddWithoutValidate(String, String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Inserts a header into the collection without checking whether the header is on the restricted header list.
protected:
void AddWithoutValidate(System::String ^ headerName, System::String ^ headerValue);
protected void AddWithoutValidate (string headerName, string? headerValue);
protected void AddWithoutValidate (string headerName, string headerValue);
member this.AddWithoutValidate : string * string -> unit
Protected Sub AddWithoutValidate (headerName As String, headerValue As String)
Parameters
- headerName
- String
The header to add to the collection.
- headerValue
- String
The content of the header.
Exceptions
headerName
is null
, Empty, or contains invalid characters.
-or-
headerValue
contains invalid characters.
.NET Framework and .NET Core only: headerName
is not null
and the length of headerValue
is too long (greater than 65,535 characters).
Remarks
The AddWithoutValidate method adds a header to the collection without checking whether the header is on the restricted header list.
Note
The length of headerValue
is validated only in .NET Framework and .NET Core versions 2.0 - 3.1.
- On all applicable .NET Framework versions: A WebHeaderCollection instance that's returned by the Headers property will throw an ArgumentOutOfRangeException if the length of
headerValue
is greater than 65535. All other WebHeaderCollection instances accept aheaderValue
of any length. - On .NET Core versions through version 3.1: A WebHeaderCollection instance used with any header of type HttpResponseHeader will throw an ArgumentOutOfRangeException if the length of
headerValue
is greater than 65535. All other WebHeaderCollection instances accept aheaderValue
of any length. - On .NET 5 and later versions: WebHeaderCollection accepts a
headerValue
of any length.
Notes to Inheritors
Use the AddWithoutValidate(String, String) method to add headers that are normally exposed through properties.