Preparing your ASP Pages for a Transition to ASP.NETBy Darren Neimke and Scott Mitchell
|About this Article|
This article briefly examines the design and development changes in ASP.NET from classic ASP.
(For those who are unaware, ASP.NET is Microsoft's next "version" of ASP. If you are unfamiliar
with ASP.NET it is highly recommended that you read some of the introduction articles at
the ASP.NET Article Index.) This article focuses on
looking at how to write your ASP code today to make it easier to port the ASP code you write today
into future ASP.NET code.
Also keep in mind that both ASP and ASP.NET can run simultaneously on a Web server. When moving to ASP.NET you are not required to migrate all of your ASP pages to ASP.NET pages. However, you may wish to due to ASP.NET's enhanced performance and better code maintainability and readability over classic ASP.
One of the biggest changes developers migrating from classic ASP to ASP.NET will have to deal with is ASP.NET's radical shift in the way dynamic Web pages are built. ASP pages consist of interpretted script code often presented in procedural terms. The script begins processing the first line of code in the ASP page and works its way down. The code in an ASP page is used, essentially, to directly fiddle and customize the HTML that is sent to the client (the Web visitor's browser).
With ASP.NET, however, dynamic Web pages are compiled programs adhering to object-oriented programs methodologies. While ASP.NET pages can simply use blocks of HTML like classic ASP page, ASP.NET encourage the use of Web controls, which are black-box type server-side tags that produce HTML. For example, with classic ASP one would create a simple postback form that outputs the user's entries with the following code:
Note the intricate mixing of HTML and ASP code (such as in the
value parameter in the
txtName INPUT tag). The corresponding ASP.NET page, utilizing Web controls (sometimes referred to
as server controls), would be much cleaner and simpler:
Note the many fundamental stylistic coding differences in the ASP.NET example as compared to the classic ASP
example. Execution of the ASP page begins with the first line of code; execution of the ASP.NET page begins with
Page_Load event handler. The ASP.NET page utilizes Web controls while the ASP page shamelessly
mixes code and content.
This article, however, is not intended to present the differences among classic ASP and ASP.NET. To learn more about these fundamental differences check out: Transitioning to ASP.NET: Server Controls. This article examines, in detail, server controls, and how they can and should be used in an ASP.NET page. Also be sure to check out the many great articles listed in the 4Guys ASP.NET Article Index.
Now that we've looked at ASP.NET's anatomy and compared that to classic ASP's anatomy, you may be wondering,
"How do I get my classic ASP code ready to upgrade to .NET?" Due to these major differences between ASP and
ASP.NET, simply renaming an ASP page from
.aspx (the extension for ASP.NET pages)
will rarely produce error-free code. Since, at the time of this article's writing (April 16th, 2001), ASP.NET
is still in Public Beta 1, you may be hesitant on starting ASP.NET development. However, it would be very wise to
start writing your classic ASP pages in a format that makes it easier to transition to ASP.NET once ASP.NET concludes
In Part 2 we will look at what, specifically, we need to change when creating ASP pages today to make our migration to ASP.NET simpler.