Migrating ASP to ASP.NET
Surpinsingly for me. I found that some friends were working
on migrating an ASP classic site to ASP.NET. I was impressed to see that there
are still sites in ASP classic at ALL!!!!
ASP.NET 2.0 provides so much improvements, you cannot even
debug in ASP. ASP.NET 2.0 has better performance and easier to deploy. There is
even Intellisense! These days is hard for me not assuming that all IDEs provide
the developer aids like that.
Also migrating simple ASP classic code to ASP.NET is not
that hard.
Let’s see a simple ASP classic page like:
<%
Dim objConn
Dim objRS
Set objConn =
Server.CreateObject(“ADODB.Connection”)
Set objRS =
Server.CreateObject(“ADODB.Recordset”)
objConn.ConnectionString
= “DRIVER=(SQL Server);server=…”
objConn.Open()
objRS.Open “SELECT *
from Items”, objConn
Do While Not
objRS.EOF
Response.Write CStr(objRS(“ID”)) + “ – “ + objRS(“Description”)
+ “<br>”
objRS.MoveNext
Loop
objConn.Close
%>
Migrates easily to:
<%@ Page aspcompat=true Language=”VB” AutoEventWireUp=”false”
CodeFile=”Default.aspx.vb” >
<%
Dim objConn
Dim objRS
Set objConn =
Server.CreateObject(“ADODB.Connection”)
Set objRS =
Server.CreateObject(“ADODB.Recordset”)
objConn.ConnectionString
= “DRIVER=(SQL Server);server=…”
objConn.Open()
objRS.Open (“SELECT
* from Items”, objConn)
Do While Not
objRS.EOF
Response.Write (CStr(objRS(“ID”).Value) + “
– “ + objRS(“Description”).Value + “<br>”)
objRS.MoveNext
Loop
objConn.Close
%>
These are the task to do:
- Remove
SET
- Any method
in ASP.NET requires its parameters to go inside parenthesis
- ASP.NET
does not have default properties so elements as objRS(“ID”) must be
changed to objRS(“ID”).Value and objRS(“Description”) to objRS(“Description”).Value
- you
must add the aspcompat=true property to the page because of the apartment threading
issues
- You
should change statements like Dim objRS to Dim objRS as Object it is not
an error but it will help you make your code more clear.
You can also download the Migration Assitant from ASP to
ASP.NET from:
http://www.asp.net/DownloadWizard.aspx?WizardTarget=AspToAspNetMigrationAssistant