Develop dynamic Web pages that leave ASP in the dust
In two previous articles, I covered the fundamentals of the Microsoft .NET Framework and ASP.NET as they relate to the IIS administrator. The first article, "Get Ready for .NET," May 2002, InstantDoc ID 24479, provides an introduction to the .NET Framework. I explain where you can obtain the .NET Framework and outline the client and server installation requirements. I also explain the .NET Framework's two major components: the Common Language Runtime (CLR) and the .NET Framework class library.
The second article, "ASP.NET Security," June 2002, InstantDoc ID 24838, digs deep into the inner workings of ASP.NET as they relate to designing, configuring, and implementing ASP.NET's security architecture. I introduce ASP.NET's security features, describe the relationship between ASP.NET and IIS, and explain how to use two componentsmachine.config and web.configto configure ASP.NET security.
Now that you have an understanding of how ASP.NET and IIS work together, you can begin to optimize ASP.NET performance for IIS. Specifically, you can take advantage of ASP.NET's performance and use ASP.NET caching to create high-performance IIS applications.
A Faster ASP
In case you haven't heard, ASP.NET is fastreally fastespecially when you compare it with Active Server Pages (ASP). At the time of this writing, no independent testing figures were available to gauge ASP.NET's performance against ASP and other platforms. However, initial reports from within Microsoft indicate that ASP.NET on IIS 6.0 on Windows .NET Server (Win.NET Server) straight out of the box, without any special configuration, will run a minimum of 75 percent faster than ASP on IIS 5.0. The handful of ASP.NET applications I've worked with have been a joy from a performance perspective.
ASP.NET code is faster than ASP code, in large part because the former is compiled rather than interpreted. Compiling ASP.NET code permits early binding, strong typing, and just-in-time (JIT) conversion of the processing server's native code. Also, ASP.NET takes advantage of .NET Framework and CLR enhancements such as caching.
When a user requests an ASP page, ASP interprets the page code for each request in the order that the page code appears on the page (i.e., top to bottom). However, the first time someone requests an ASP.NET page, ASP.NET dynamically compiles an instance of the page class, which represents the code for the ASP.NET page, then caches the page class on the server for subsequent requests. (In fact, ASP.NET automatically caches many componentse.g., internal objects, such as server variablesto speed user access to them.) For subsequent page requests, ASP.NET executes the cached instance of the page class. However, if you change the original source code for an ASP.NET page or one of its dependencies, the JIT compiler automatically recompiles the page class.
The page class is usually part of a "code-behind" modulea separate physical file from the HTML filethat, together with the HTML file, makes up an ASP.NET page. The CLR JIT compiler compiles ASP.NET-managed page code to the processing server's native code at runtime.
Another performance advantage of ASP.NET is that it's factorable, which means that IIS administrators and developers can easily remove existing modules (e.g., a session-state module, a trace-logging module) that aren't relevant to the application they're developing. ASP.NET's extensive caching services include both built-in services and caching APIs.
Performance Monitoring
ASP.NET improves on ASP's performance monitoring. Whereas ASP exposes performance counters globally for an entire server, ASP.NET exposes many performance counters on a per-application basis. And in many cases, just one line of code adds a performance counter to an ASP.NET application.
You can view counters for an ASP.NET application under the ASP.NET Applications performance object in System Monitor. (To open System Monitor, open the Control Panel Administrative Tools applet and double-click Performance.) If you have multiple ASP.NET applications on your servers, you must select a particular application instance before selecting a counter to monitor. However, a special __Total__ application instance in System Monitor aggregates the performance-counter values for all applications on a server. For example, Figure 1 shows System Monitor monitoring __Total__ and the ASP.NET application _LM_w3svc_1_root_MyMSEvents, which my company wrote for Microsoft to manage large events such as TechEd, MEC, and Fusion.
ASP.NET also exposes global-only counters not bound to a particular application instance. To configure System Monitor to monitor performance of all global and application-specific counters, click the View Report (dog-eared report) icon next to the Add (plus symbol) icon in the Performance console. Next, click the Add icon. Select ASP.NET Applications from the Performance object drop-down menu, select All counters and All instances, then click Add. Next, select ASP.NET (System) from the Performance object drop-down menu, select All counters, then click Add.