Export (0) Print
Expand All

HttpEncoder.HeaderNameValueEncode Method

Encodes a header name and value into a string that can be used as an HTTP header.

Namespace:  System.Web.Util
Assembly:  System.Web (in System.Web.dll)

protected internal virtual void HeaderNameValueEncode(
	string headerName,
	string headerValue,
	out string encodedHeaderName,
	out string encodedHeaderValue
)

Parameters

headerName
Type: System.String
The HTTP header name to encode.
headerValue
Type: System.String
The HTTP header value to encode.
encodedHeaderName
Type: System.String%
When this method returns, contains the encoded name to use for an HTTP header. This parameter is passed uninitialized.
encodedHeaderValue
Type: System.String%
When this method returns, contains the encoded value to use for an HTTP header. This parameter is passed uninitialized.

The HeaderNameValueEncode method takes input strings from the headerName and headerValue parameters and encodes them. The encoded values are returned as out parameters.

The HeaderNameValueEncode method uses the following logic to encode header names and values:

  • All characters whose Unicode value is less than ASCII character 32, except ASCII character 9, are URL-encoded into a format of %NN where the N characters represent hexadecimal values.

  • ASCII character 9 (the horizontal tab character) is not URL-encoded.

  • ASCII character 127 is encoded as %7F.

  • All other characters are not encoded.

    NoteNote

    Although this method can be used for Unicode values, it is typically used for values in the ASCII range.

The default implementation of the HeaderNameValueEncode method returns the value of headerValue in encodedHeaderValue if headerValue is null or is an empty string. Similarly, the default implementation returns the value of headerName in encodedHeaderName if headerName is null or is an empty string.

.NET Framework

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft