Chapter 18. The HttpServerUtility Class
The HttpServerUtility
class is ASP.NET’s
replacement for ASP’s intrinsic Server object.
Because the Server property of the Page class
(from which all pages are derived) exposes the
HttpServerUtility class instance for a given
ASP.NET page, you can code to the
HttpServerUtility class as you did in the Server
object in classic ASP, meaning that your existing ASP code is much
easier to migrate.
The HttpServerUtility class performs utility
functions such as encoding and decoding strings for use in URLs or
for plain-text display of content that may contain HTML markup tags.
The HttpServerUtility class also provides access
to limited error information and provides methods (Execute, Transfer)
for modifying the execution of the current request. Table 18-1 lists the properties and methods exposed by
the HttpServerUtility class.
Table 18-1. HttpServerUtility class summary
|
Properties |
Collections |
Methods (public instance) |
|---|---|---|
|
MachineName |
None |
ClearError |
|
ScriptTimeout |
CreateObject | |
|
CreateObjectFromClsid | ||
|
Execute | ||
|
GetLastError | ||
|
HtmlDecode | ||
|
HtmlEncode | ||
|
MapPath | ||
|
Transfer | ||
|
UrlDecode | ||
|
UrlEncode | ||
|
UrlPathEncode |
Comments/Troubleshooting
In classic ASP, the Server object was used to create COM component instances by using the Server.CreateObject method. CreateObject still exists in ASP.NET, along with a new method, CreateObjectFromClsid, which uses a COM class ID (CLSID) instead of a ProgID to locate the object to create. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access