Name
HttpServerUtility
Synopsis
This class provides helper methods and is available through the built-in Server
object. It provides the useful UrlEncode()
method,
which converts a string into a form suitable for use as a query
string variable, and the HtmlEncode()
method,
which converts nonlegal HTML characters in a string into the
equivalent HTML entity (i.e., "<"
is converted
to <
) so they can be displayed on a page. Some
ASP.NET web controls (like buttons) do not require this conversion, but
label controls do. You may need to use the HtmlEncode()
method manually if
you bind a field with URL information from a database.
The HttpServerUtility
class provides the MapPath()
method, which
takes a string representing a virtual path and returns the real
(physical) path (for example, it could convert "/myapp/index.html"
to "E:\Inetpub\wwwroot\myapp\index.html"
). It also
provides a CreateObject()
method
for instantiating a COM object by using its ProgID (i.e., objInfo=Server.CreateObject ("MSWC.MyInfo")
) and the
two flow control methods Execute()
and Transfer()
. The Execute()
method, which runs
the script in a separate ASP.NET page and then returns control to the
current page, is rarely used in class-based ASP.NET programming. The Transfer()
method halts
the execution of the current page and transfers execution to the
specified page. It is similar to the HttpResponse.Redirect()
method, but does not require a roundtrip to the client and back and cannot transfer execution to a page on ...
Get ASP.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.