www.gibmonks.com

Main Page

  Previous Section Next Section

18.1 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_Load event handler for that particular example. Any output messages or return values displayed are shown as the Text property of the ASP.NET Label named Message, or displayed by calling Response.Write.

<%@ Page Language="vb" %>
<html>
   <head>
      <script runat="server">
         Sub Page_Load( )
            'Example code will go here
         End Sub
      </script>
   </head>
<body>
   <asp:label id="Message" runat="server"/>
</body>
</html>
      Previous Section Next Section