Now that you have an idea of what needs to be changed, here are a few tips to help you get started on your migration project. The following list provides a summary of the tips discussed in this section:
Update the Web.config FileWhen you start your migration, start first with the server configuration. Depending on what new features of ASP.NET you use, such as sharing state among multiple servers, you might need to make more changes in your code. If, for example, you are storing COM objects in the Session object, you must either use a different method of storing the COM object data or migrate the COM object to a managed code object. Move Functions to Class LibrariesIf, like many developers, you have developed libraries of functions that you include in your ASP files with the #include statement, you should move these into class libraries. Doing so can reduce your redundant code and make it easier to maintain the code. Separate Code from ContentIn a related issue to moving your functions to class libraries as much as possible, separate the remainder of your code from the content as much as possible. Use ASP.NET's capability to have a code file behind the .aspx file. Move any code that is not related to rendering the page to a member function of your supporting class derived from the System.Web.UI.Page class. If you still have functions that are used to render the page declared in script blocks, consider developing custom server controls to do the rendering. This makes your code easier to read and maintain while allowing your custom server control to be used elsewhere. Minimize ASP Style #includesIn ASP, developers often use the #include statement to include HTML fragments in their files. This makes it easy to write pages that have consistent headers, footers, or advertisements. If you have already eliminated your included function libraries, you should work at eliminating these HTML fragments. Here again, custom server controls can be developed to render these fragments . Use the Option Strict KeywordUsing the Option Strict keyword forces you to write the best code. You get the best performance if you use the necessary early binding syntax that Option Strict enforces. You also minimize errors caused by assigning data of the wrong type to the wrong variable. Migrate COM Objects to Managed Code ComponentsAlthough this is not the most critical action, you will gain a performance boost by migrating your COM objects to managed code. This is especially true if your COM objects are business logic written in Visual Basic with the STA threading model. If you use Visual Basic to write your COM objects, it should be fairly easy to migrate them to managed code written with Visual Basic .NET. If you keep the same object interfaces, you can do this after the ASP portion of the application has been migrated . Change Database Access Layer from ADO to ADO.NETBecause ADO.NET scales better than ADO, you can gain two benefits by moving your data access layer to ADO.NET. First, performance improves because ADO COM objects no longer have to be called through the COM Interop layer. This might not be too much of a gain if you make most of your calls to the ADO COM object from within other COM objects, but if you use ADO directly from ASP, it can be significant. Second, you reduce your overall system load when you use the disconnected recordset model used by ADO.NET. Additional information about ADO.NET can be found in Chapter 9, "ADO.NET in ASP.NET." |