Thursday, December 21, 2006

The Server object of ASP.NET / HttpServerUtility




The methods and properties of the HttpServerUtility class are exposed through the intrinsic Server object provided by ASP.NET.

HttpServerUtility provides helper methods for processing Web requests.

The HtmlEncode method helps ensure that any user-supplied string input will be rendered as static text in browsers instead of executable script code or interpreted HTML elements.

The UrlEncode method encodes URLs so that they are correctly transmitted in the HTTP stream.

For examples:



The HttpUtility class exposes methods for encoding and decoding string based URLs, URL tokens, and paths. The HttpUtility is used internally by the HttpServerUtility class.
Additionally, the HttpUtility class contains encoding and decoding utility methods that are not accessible from the Server.

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