Export (0) Print
Expand All

HttpUtility Class

Provides methods for encoding and decoding URLs when processing Web requests. This class cannot be inherited.

System::Object
  System.Web::HttpUtility

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

public ref class HttpUtility sealed

The HttpUtility type exposes the following members.

  NameDescription
Public methodHttpUtilityInitializes a new instance of the HttpUtility class.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberHtmlAttributeEncode(String)Minimally converts a string to an HTML-encoded string.
Public methodStatic memberHtmlAttributeEncode(String, TextWriter)Minimally converts a string into an HTML-encoded string and sends the encoded string to a TextWriter output stream.
Public methodStatic memberHtmlDecode(String)Converts a string that has been HTML-encoded for HTTP transmission into a decoded string.
Public methodStatic memberHtmlDecode(String, TextWriter)Converts a string that has been HTML-encoded into a decoded string, and sends the decoded string to a TextWriter output stream.
Public methodStatic memberHtmlEncode(Object)Converts an object's string representation into an HTML-encoded string, and returns the encoded string.
Public methodStatic memberHtmlEncode(String)Converts a string to an HTML-encoded string.
Public methodStatic memberHtmlEncode(String, TextWriter)Converts a string into an HTML-encoded string, and returns the output as a TextWriter stream of output.
Public methodStatic memberJavaScriptStringEncode(String)Encodes a string.
Public methodStatic memberJavaScriptStringEncode(String, Boolean)Encodes a string.
Public methodStatic memberParseQueryString(String)Parses a query string into a NameValueCollection using UTF8 encoding.
Public methodStatic memberParseQueryString(String, Encoding)Parses a query string into a NameValueCollection using the specified Encoding.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodStatic memberUrlDecode(String)Converts a string that has been encoded for transmission in a URL into a decoded string.
Public methodStatic memberUrlDecode(array<Byte>, Encoding)Converts a URL-encoded byte array into a decoded string using the specified decoding object.
Public methodStatic memberUrlDecode(String, Encoding)Converts a URL-encoded string into a decoded string, using the specified encoding object.
Public methodStatic memberUrlDecode(array<Byte>, Int32, Int32, Encoding)Converts a URL-encoded byte array into a decoded string using the specified encoding object, starting at the specified position in the array, and continuing for the specified number of bytes.
Public methodStatic memberUrlDecodeToBytes(array<Byte>)Converts a URL-encoded array of bytes into a decoded array of bytes.
Public methodStatic memberUrlDecodeToBytes(String)Converts a URL-encoded string into a decoded array of bytes.
Public methodStatic memberUrlDecodeToBytes(String, Encoding)Converts a URL-encoded string into a decoded array of bytes using the specified decoding object.
Public methodStatic memberUrlDecodeToBytes(array<Byte>, Int32, Int32)Converts a URL-encoded array of bytes into a decoded array of bytes, starting at the specified position in the array and continuing for the specified number of bytes.
Public methodStatic memberUrlEncode(array<Byte>)Converts a byte array into an encoded URL string.
Public methodStatic memberUrlEncode(String)Encodes a URL string.
Public methodStatic memberUrlEncode(String, Encoding)Encodes a URL string using the specified encoding object.
Public methodStatic memberUrlEncode(array<Byte>, Int32, Int32)Converts a byte array into a URL-encoded string, starting at the specified position in the array and continuing for the specified number of bytes.
Public methodStatic memberUrlEncodeToBytes(array<Byte>)Converts an array of bytes into a URL-encoded array of bytes.
Public methodStatic memberUrlEncodeToBytes(String)Converts a string into a URL-encoded array of bytes.
Public methodStatic memberUrlEncodeToBytes(String, Encoding)Converts a string into a URL-encoded array of bytes using the specified encoding object.
Public methodStatic memberUrlEncodeToBytes(array<Byte>, Int32, Int32)Converts an array of bytes into a URL-encoded array of bytes, starting at the specified position in the array and continuing for the specified number of bytes.
Public methodStatic memberUrlEncodeUnicode Obsolete. Converts a string into a Unicode string.
Public methodStatic memberUrlEncodeUnicodeToBytes Obsolete. Converts a Unicode string into an array of bytes.
Public methodStatic memberUrlPathEncodeDo not use; intended only for browser compatibility. Use UrlEncode.
Top

The HttpUtility class is used internally by the HttpServerUtility class, whose methods and properties are exposed through the intrinsic ASP.NET Server object. Additionally, the HttpUtility class contains encoding and decoding utility methods that are not accessible from the Server.

To encode or decode values outside of a web application, use the WebUtility class.

The following code example demonstrates the use of the UrlEncode, UrlDecode and ParseQueryString methods of the HttpUtility class.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft