
386
|
Chapter 18: The HttpServerUtility Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
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. You should use both
methods only when necessary, since even though the details are handled for you,
using these methods incurs the cost of interoperating between COM and .NET
(unmanaged and managed) code. If there is a .NET alternative to using a COM
object, you will get better performance by sticking with the .NET solution.
The ASP.NET version of the Server object also adds a number of useful new utility
functions, including HtmlDecode, UrlDecode, and UrlPathEncode. HtmlDecode
and UrlDecode are particularly welcome, given that classic ASP developers were
stuck either manually implementing functionality to remove URL or HTML
encoding from strings that they’d encoded on another page or relying on third
party components or scripts to do so. Now this functionality is built in.
In this chapter, we’ll use the following code listing as the basis for most examples
in the chapter. Unless otherwise noted, each example will consist of the Page_ ...