Export (0) Print
Expand All

WebUtility.UrlEncodeToBytes Method

.NET Framework 4.5

Converts a byte array into a URL-encoded byte array.

Namespace:  System.Net
Assembly:  System (in System.dll)

static member UrlEncodeToBytes : 
        value:byte[] * 
        offset:int * 
        count:int -> byte[] 

Parameters

value
Type: System.Byte[]

The Byte array to URL-encode.

offset
Type: System.Int32

The offset, in bytes, from the start of the Byte array to encode.

count
Type: System.Int32

The count, in bytes, to encode from the Byte array.

Return Value

Type: System.Byte[]
Returns Byte.
An encoded Byte array.

If characters such as blanks and punctuation are passed in an HTTP stream, they might be misinterpreted at the receiving end. URL encoding replaces characters that are not allowed in a URL with character-entity equivalents consisting of hexadecimal escape sequences. The converted string is expected to conform to the UTF-8 format.

URL encoding replaces all character codes except for letters, numbers, and the following punctuation characters:

  • - (minus sign)

  • _ (underscore)

  • . (period)

  • ! (exclamation point)

  • * (asterisk)

  • ' (single quotation mark)

  • ( and ) (opening and closing parentheses)

For example, when embedded in a block of text to be transmitted in a URL, the characters < and > are encoded as %3c and %3e.

The UrlDecodeToBytes method reverses the encoding.

.NET Framework

Supported in: 4.5

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft