HeaderNameValueEncode Method
Collapse the table of content
Expand the table of content

HttpEncoder.HeaderNameValueEncode Method (String, String, String, String)

.NET Framework (current version)
 

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)

abstract HeaderNameValueEncode : 
        headerName:string *
        headerValue:string *
        encodedHeaderName:string byref *
        encodedHeaderValue:string byref -> unit
override HeaderNameValueEncode : 
        headerName:string *
        headerValue:string *
        encodedHeaderName:string byref *
        encodedHeaderValue:string byref -> unit

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.

    System_CAPS_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
Available since 4.0
Return to top
Show:
© 2016 Microsoft