This article may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. To maintain the flow of the article, we've left these URLs in the text, but disabled the links.
Migrating Your ASP Apps from Windows NT 4.0 to Windows 2000 |
||||||||||||||||
Shelley Powers | ||||||||||||||||
|
||||||||||||||||
ow that Windows® 2000 has been released, you're probably taking a close look at your ASP applications, thinking about migrating them from Windows NT® 4.0. Of course you'll want to know if your current ASP applications work in Windows 2000 without changes. After all, migrating applications is not a trivial exercise. What exactly does it take to make your ASP applications move smoothly from Windows NT to Windows 2000?
Installation and ConfigurationIf you install Windows 2000 to a clean machine or to dual-boot with Windows NT, you can choose to install IIS as part of the operating system installation, or you can install the Web server later. When you upgrade an existing installation of Windows NT to Windows 2000, IIS 5.0 is installed automatically if the installer for Windows 2000 detects a previous version of IIS on your machine. The installation program also migrates the current IIS settings to the new environment wherever there are compatible settings between the two Web server versions.When you're migrating a production ASP environment, I recommend that you install Windows 2000 on a clean (newly formatted) hard drive and avoid dual-boot configurationsâ€"except perhaps on development machines. New Properties in IIS 5.0 and ADSIOnce IIS 5.0 is installed, you'll find that the Internet Services Manager (ISM) Management Console for IIS 5.0 differs somewhat from the one used with IIS 4.0. For instance, in the Virtual Directory tab or the Home Directory tab for a Web site (see Figure 1) the access and content control permissions are no longer grouped separately, and one new item has been added, "Script source access." Checking this new option allows Web access of script resources. To ensure that your script is not accessible, make sure this option is unchecked (the default setting).
Another significant difference relates to controlling the ASP application settings. Instead of the checkbox option to run the application in a separate process, the choices are in a dropdown listbox labeled Application Protection, which contains three options: Low (IIS Process), Medium (Pooled), and High (Isolated). In Figure 1, the Medium option is selected.
If you prefer, you can create your own administrative ASP script to modify both CPU tracking and throttling. The ASP page shown in Figure 3 enables CPU throttling (using the default throttling of 10 percent) and also modifies the existing CPU tracking by turning on specific fields to print (matching those settings shown in Figure 2). This ASP page will then run within a restricted, administrative environment. Set up SecurityYou'll want to set up application security that's comparable to or better than what you had in your Windows NT-based installation. I have some good news for you; there are more security options, more granularity of security, and more consistent application of security for your Web applications within Windows 2000. And there are also some handy new security wizards in IIS to help walk you through the security settings.Your first line of defense in Windows 2000 is the same as it was in Windows NT: setting the file and folder access permissions with NTFS. Web security lacks the granularity you get with NTFS, and if you want to fine-tune which users can read or write to a file or folder or execute a particular application, set the access permissions with NTFS. While you are setting the permissions, note that the anonymous Web user is still IUSR_machinename, as it was with Windows NT. Two wizards are used to set up certificates and assign certificate trust lists (CTL). You can run the Web Server Certificate Wizard by accessing the Directory Security property sheet for the Web site and then clicking on the Server Certificate button in the page. The Certificate Wizard will pop open and ask you for information about the certificate to be set up for the site, such as the name of the certificate and locale information for the Web server. The wizard then generates a certificate request file that you can send to the certificate authority, as shown in Figure 4.
Once a certificate is installed, you can assign a CTL to it by accessing the IIS Directory Security property sheet for the site and choosing the Edit button to edit an existing certificate. This runs the CTL wizard. Migrate MTS Packages to COM+If you use ASP components and transactions within your existing ASP applications, then you've created MTS packages to group your components. In Windows 2000, MTS has been integrated into COM+ so component packaging is now handled through Component Services, and MTS packages have been replaced by COM+ applications. However, you can easily migrate your MTS packages to COM+ applications using one of two techniques, depending on whether you've chosen to upgrade or do a new install of the operating system.If you upgrade, your MTS packages are upgraded to COM+ applications automatically via the installer utility MTSTOCOM. Any errors in the conversion process are reported during the installation, and the results of this automated conversion are written to a file, Mtstocom.log, created in the Windows directory. If you've done a new install of Windows 2000, you can export your MTS packages into MTS Package Files (with a .pak extension) to move to the new environment. Then create a new COM+ application for each MTS package by following these steps:
MTS components in the packages are migrated to the new COM Services environment with all of the behavior that the component possessed within Windows NT. If the component supported transactions originally, it still supports transactions in the new environment. If the component participated in just-in-time (JIT) activation in Windows NT, it continues to participate in JIT activation in Windows 2000. However, your component won't automatically be updated to use new COM+ options such as object pooling and queuing. The reason for this is discussed in the next section. Changes to ASP Components in Windows 2000If there is one ASP application area where you would expect to see an impact based on differences between Windows NT 4.0 and Windows 2000 it is within your ASP components. After all, most ASP components are also MTS components, and MTS has been integrated into COM+ in the new environment. In addition, there are significant changes in how components are managed in COM+, such as object pooling, queuing, and other new options. Considering all the differences, you might be surprised at the ease of migrating your components to Windows 2000. To demonstrate, I'll take a look at migrating components created using Visual Basic® 6.0 and Visual C++® 6.0. First, though, I'll have to set up the development environment within Windows 2000.The first step in setting up the development machine is to install Visual Studio 6.0, as well as the Visual Studio Service Pack 3. Once Visual Studio is installed, open Visual C++, and then close the applicationâ€"you'll see the reason in a moment. If you're developing ASP components using Visual Studio, and particularly if you're using Visual C++, you're also going to want to install the January 2000 (or later) edition of the Platform SDK. You can access the Platform SDK from the MSDN Online SDK area (https://msdn.microsoft.com/downloads/default.asp?URL=/code/topic.asp?URL=/msdn-files/028/000/123/topic.xml); if you have a Universal or Professional MSDN subscription, you'll find it on the CDs. When you install the Platform SDK, you can select which components you want in your own environment. At a minimum you'll want to select the Configuration Options, which includes Integrate with Visual C++, and the Build Environment option (see Figure 6). If you have room, I strongly recommend installing the documentation as well. Selecting the Build option installs the libraries and header files for working with COM+, and the integration option actually integrates these into Visual C++ by adding the Platform SDK libraries and header files as the first entries in the include and source file directories.
An interesting thing happens when you select the Integrate with Microsoft Visual C++ option. Visual C++ has to be opened first for this process to happen correctly. If you don't open it first, the directories are added after all other directories installed with Visual Studio, rather than first in the list. You'll then have to manually adjust the listing location to move the directories to the first positions in the include and library paths. As you'll see a little later, the Platform SDK libraries and include files must be first in the list to work with Visual C++ in Windows 2000. Components from Visual BasicAfter copying one or more of your Visual Basic component projects to the new operating system, open any project that previously used the MTS type library (mts.dll). Checking the references for the project, you're going to find that the reference to the MTS type library no longer appears. Instead, the COM+ Services Type Library, comsvcs.dll, is now listed, as shown in Figure 7. How did this happen? Through the magic of COM, of course.
When Microsoft created the new COM Services component, it provided all of the existing functionality of MTS, and more. To make sure that this new functionality was automatically accessible to components moving to Windows 2000, Microsoft gave the COM Services component the exact same CLSID that was used by the older MTS component. Visual C++ Components in Windows 2000If you use Visual C++ to create your ASP components, the Platform SDK installation should add the SDK libraries and header files to your build environment, as shown in Figure 9. As with the Visual Basic environment, you should be able to recompile your ASP components in Visual C++ with little or no intervention. This includes any ASP or MTS components you created using the ATL component wizards.
When creating a new ASP component, the Visual C++ 6.0 ATL wizard used the ScriptingContext object, along with the OnStartPage and OnEndPage event handlers, to instantiate the ScriptingContext object, create instances of the ASP built-in objects, and to perform any cleanup. These components will work within the Windows 2000 and IIS 5.0 environment, as Microsoft is maintaining a reference to the ScriptingContext object within IIS 5.0 for backward compatibility. |
#include <mtx.h>
MTS doesn't exist within the Windows 2000 environment. It has been replaced by COM+. Also, the MTS library is no longer supported; it has been replaced by the COM Services library. So, how can MTS components successfully compile or work?
The answer is apparent when you open the mtx.h header file that comes with the Platform SDK:
// Copyright (C) 1995-1999 Microsoft
// Corporation. All rights reserved.
#define __MTxSpm_LIBRARY_DEFINED__
#include "comsvcs.h"
The mtx.h file included in the new Platform SDK is nothing more than a wrapper for the new COM Services header file. Checking the external dependencies for a project built with Visual C++, you'll find that comsvcs.h, rather than mtx.h, is included in this list. This file is one of the reasons why it is essential that the Platform SDK library and include files are placed before those installed with Visual Studioâ€"to ensure that you pick up the correct version of the header files used in your components, such as mtx.h.
You can actually change the include file directly in your component using the following, instead of using a reference to mtx.h:
#include <comsvcs.h>
However, this doesn't really affect the end resultâ€"an ASP component that can be registered in a COM+ application and accessed from ASP pages in Windows 2000.
As stated earlier, your migrated components have the same component services in Windows 2000 that they had in Windows NT 4.0. However, there are new services available with COM+ that you won't necessarily be able to use without more serious consideration and more extensive modification of the ASP components.
Object Pooling
One new COM+ feature you'll be interested in is object pooling, which allows components to be created within a pool of reusable objects, decreasing the amount of time necessary to instantiate the objects. Object pooling was not implemented in Windows NT 4.0; it's new in Windows 2000. You might be tempted to add the object pooling option (see Figure 10) when you add your existing Visual Basic and Visual C++-based components to COM+ applications through Component Services. However, you will find that none of your Visual Basic-based components can be pooled, and it is unlikely that any of your Visual C++-based components can be.
Figure 10Object Pooling |
Visual Basic components can't be pooled because they're apartment threaded, and a requirement of object pooling is that the component be able to run in either the neutral-threaded or the multithreaded apartment (MTA).
Components built with Visual C++ can be marked both-threaded, meaning they run within the MTA, so they meet the threading requirement of object pooling. However, if the components were created as MTS components, they won't support object pooling. Object pooling requires that the component supports aggregation, but MTS required that the component not support aggregation. In fact, when creating the MTS component using ATL, a macro that prevents the component from being aggregated is added to the component's header file:
DECLARE_NOT_AGGREGATABLE(CComponent)
An additional requirement of object pooling is that any resources allocated within the component must be handled by the component (and that the component doesn't maintain client state), which means additional work to make sure the component is poolable as defined by Windows 2000. So you're going to have to do some work before you can use object pooling with your MTS components in Visual C++, and you're not going to be able to use object pooling with your Visual Basic-based components at all, at least for now.
However, your components still have access to the functionality they had in Windows NT 4.0, and that's really what you care about when migrating them and their associated ASP applications to Windows 2000.
Once you've set up your ASP development environment and migrated your ASP components and MTS packages, it's time to unit test the applications. Now let's take a closer look at what has changed in ASP itself in Windows 2000.
Differences in the ASP Object Model
The ASP object model is different in IIS 5.0, with the addition of new methods as well as changed behavior for some existing methods and properties. One of the most significant changes is that buffering is now enabled by default for an ASP application, where previously buffering was disabled by default. With this change, all ASP script in the page is processed before any page contents are returned. Default buffering could impact your existing ASP applications that perform longer database queries or other time-consuming operations.
For example, I created a simple little ASP page containing a loop that is executed two million times, with code setting a single variable to zero within the loop. The code is nonsensical, but its purpose is to generate a process within the ASP page that takes enough time to be humanly noticeable. I then added a Response.Write statement before and after the loop:
<HTML>
<HEAD>
<BODY>
<%
Response.Write "<h3>About to perform long loop</h3>"
Dim i, j
For i = 1 To 2000000
j = 0
Next
Response.Write "<h3>Long loop is finished</h3>"
%>
</BODY>
</HTML>
I temporarily turned off the buffering for the ASP application that contains this page. You can disable buffering for an entire application by accessing the Configuration properties for the application and unchecking the Enable Buffering option in the App Options property sheet. You can access the Configuration properties by clicking the button labeled Configuration in the Virtual Directory property sheet for a virtual directory or in the Home Directory property sheet for a Web site.
The first header is written out and returned to the client before the loop finishes. The second header is then printed out after the loop is finished (this takes a few seconds). However, when I turn buffering back on, as shown in Figure 11, no content is displayed in the page until all of the processing is finished.
Figure 11Enable Buffering |
If your ASP applications have longer database queries or other processes, and you have been using output to tell the client that processing is occurring, you might want to turn buffering off for the affected ASP application. Or you might want to modify your affected ASP pages and turn buffering off through the Response object, or flush the buffer before executing any long process.
If you have ASP applications that have been working with buffered content, you don't have to change the code before migrating the application. The redundant setting of the buffering property doesn't impact the application, other than the time it takes to process the script:
<% Response.Buffer = True %>
Another change that should have little impact when migrating your existing ASP applications is that the IsConnected property now responds correctly regardless of whether the ASP page is returning content. Previously, this property would not work correctly if the ASP page didn't return content. Chances are, though, if you've used this property in your existing application, you've already coded around the property's previous limitationsâ€"and the existing code should work just fine in IIS 5.0, as it did in IIS 4.0. ConclusionIn this article, I've provided a multi-step process you can use to create a plan for migrating your existing ASP applications to Windows 2000. Additionally, I hope I've provided enough detail about this planâ€"setting up IIS 5.0, Web security, creating the ASP development environment for both Visual Basic and Visual C++-based component development, migrating your MTS packages to COM+ applications, and handling ASP differencesâ€"to give you a clear idea of what you're facing with each migration step.You're going to find that migrating your ASP applications to Window 2000 doesn't have to be an overwhelming task, and that you can take advantage of some of the Windows 2000 functionality with little or no effort, and with little or no impact to your existing applications. |
|
For related articles see: https://msdn.microsoft.com/workshop/server/asp/server02282000.asp https://www.microsoft.com/mind/0499/iis5/iis5.htm For background information see: https://www.microsoft.com/msj/0599/complusprog/complusprog.htm https://www.microsoft.com/msj/0999/com/com0999.htm https://msdn.microsoft.com/msdnmag/issues/0300/com/com.asp https://msdn.microsoft.com/msdnmag/issues/0300/basics/basics.asp https://msdn.microsoft.com/downloads/default.asp?URL=/code/topic.asp?URL=/msdn-files/028/000/123/topic.xml |
|
Shelley Powers, otherwise known as YASD (https://www.yasd.com), is an independent consultant in Boston, Massachusetts, and author of Developing ASP Components (O'Reilly & Associates, 1999). She can be reached at shelleyp@yasd.com. |
|
From the August 2000 issue of MSDN Magazine.