Migrate to ASP .NET: Important Issues Need Consider

zhaozj2021-02-17  105

Introduction

Although the designer of Microsoft® ASP .NET has made a lot of unremitting efforts in maintaining the backward compatibility of the ASP application, but should still understand several key before moving the web application by the ASP .NET migration. problem. In the .NET platform and ASP .NET, the prior art has improved and adopted some new technologies, thorough understanding of these techniques facilitating the simplification of this migration process, but this requires a long time.

This article explores changes in all aspects to make users clearly understand some of the work that the ASP app is established and allowing it to run in the ASP .NET environment. At the same time, it also points out some of the new features of ASP .NET, users can make full use of these new features to improve existing applications. But this is by no means a comprehensive introduction of all the new features of ASP .NET, but only focuses on some issues that need to be considered when they migrate.

I envision, because most ASP applications use Microsoft® Visual Basic® Scripting Edition (VBScript), most users choose to migrate to ASP .NET with Visual Basic .NET. Obviously, this is not required. However, if you decide to change the language while migration, you will need some additional work and it is likely to also involve changes in design and structures.

Coexist

Understand how ASP and ASP .NET coexist before discussing specific compatibility and migration issues. The ASP and ASP .NET applications can run on the server at the same time, and they do not affect each other. This is mainly due to the two technologies each use different file extensions (.asp and .aspx) and different configuration models (configured database / registry and XML-based profile). These two systems have their own processing engines.

Let a part of an application run the ASP, while the other part runs ASP .NET, which is completely possible. If you need to migrate a rapidly developed large site to ASP .NET at a small part, this feature will be greatly beneficial to you. Some users may say that it is best to migrate and deploy the entire site one-time. For some types of web applications, I think that there are many sites that don't do this: considering the absolute size, complexity and rapid changes in the site content and appearance, this way is very lack of flexibility. After all, for a profitable website, those who pick up the bag cannot allow you to stop their new features, and migrate the entire website to this hot new technology. In addition, if you migrate to ASP .NET as a long-term investment, you will want to use this opportunity to make some improvements to the structure and design as much as possible. Summary these situations, the coexistence migration of the stages is absolutely necessary.

Compatibility problem

Migrating an application to ASP .NET migration may not be an easy task; however, it should not be very difficult. ASP .NET and ASP have a very good compatibility, giving users a feeling asp .net is a full turn version of the ASP. The initial goal of the ASP .NET designer is to achieve 100% backward compatibility with ASP, but in subsequent work, they have to change this original intention to thoroughly improve this platform. But don't worry, we have made a lot of improvements as much as possible, and you should not need to work too much. The actual changes that have occurred can be summarized as the following categories:

Change Structure of Core API Change Visual Basic Language Changes in Change Status Management Problems related to changes in CMAAL Basic Language Data Access

The changes in the above aspects will be discussed in detail below.

Change of core API

The core API of the ASP consists of several inherent objects (Request, Response, and Server et al.) And their related methods. These APIs can continue to function properly under ASP .NET except for a few simple changes. All changes are related to the Request object, as shown in Table 1: Table 1: API changes

Method Change Request (item) In ASP, this method returns a string array. In ASP .NET, it returns NameValueCollection. Request.QueryString (Item) In ASP, this method returns the array of strings. In ASP .NET, it returns NameValueCollection. Request.Form (item) In ASP, this method returns a string array. In ASP .NET, it returns NameValueCollection.

As you can see, there is basically the same change for all methods involved.

If accessible Item (item) contains only a value of a specific keyword, you will not have to modify your own code. However, if a given keyword has multiple values, you will need to use other methods to return a collection of values. Also note that the collections in Visual Basic .NET are based on 0, and the collection in VBScript is based on 1.

For example, in the ASP, you will access http: //localhost/myweb/valuetest.asp? Values ​​= 10 & value = 20 request returned string values:

<%

'Output "10"

Response.Write Request.QueryString ("Values") (1)

'Output "20"

Response.write Request.QueryString ("Values") (2)

%>

In the ASP .NET, the queryString property returns the NameValueCollection object. Before retrieving the actual items you need, you need to retrieve the VALUES collection from the object. It is also important to note that the first item in the collection is to retrieve using 0 rather than 1 index:

<%

'Output "10"

Response.write (Request.QueryString.getVALUES ("Values") (0))

'Output "20"

Response.write (Request.QueryString.getVALUES ("Values") (1))

%>

The following code is the same as the running result in ASP and ASP .NET:

<%

'Output "10" and "20"

Response.write (Request.QueryString ("Values"))

%>

Structural change

Structural changes will affect the layout and coding style of Active Server Pages. You need to understand some of these information to make sure your code can run in ASP .NET.

Code block: declaration function and variable

In ASP, subroutines and global variables can be declared between code separators.

<%

DIM X

DIM STR

SUB mysub ()

"This is a string."

End Sub

%>

In ASP .NET, it is not allowed to be declared in this way. You must declare all functions and variables in the