Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

HttpEncoder.HeaderNameValueEncode Method

.NET Framework 4.6 and 4.5

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.

    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 a null reference (Nothing in Visual Basic) or is an empty string. Similarly, the default implementation returns the value of headerName in encodedHeaderName if headerName is a null reference (Nothing in Visual Basic) or is an empty string.

.NET Framework

Supported in: 4.6, 4.5, 4
Show:
© 2015 Microsoft