Friday, June 5, 2026 Sign InRegister FREE My Account Help
FDN Portal
FDN » .NET Framework » Migrating from ASP to ASP.NET

Migrating from ASP to ASP.NET

Migrating from ASP to ASP.NET

This tutorial guides you through migrating a classic ASP application to ASP.NET. ASP and ASP.NET can run side-by-side on the same IIS server, so you can migrate incrementally.

Key Differences

FeatureClassic ASPASP.NET
LanguageVBScript / JScript (interpreted)C# / VB.NET (compiled)
File extension.asp.aspx
Code structureInline with HTMLCode-behind files
State managementSession (InProc only)Session (InProc, StateServer, SQL)
Data accessADO (Recordset)ADO.NET (DataReader, DataSet)
Error handlingOn Error Resume Nexttry/catch/finally
COM objectsServer.CreateObject()Direct .NET classes (or COM Interop)

Step 1: Set Up the ASP.NET Project

  1. Create a new ASP.NET Web Application in Visual Studio .NET.
  2. Copy static files (images, CSS, JavaScript) from the ASP application.
  3. Configure the connection string in web.config:
    <configuration>
      <appSettings>
        <add key="ConnectionString"
             value="Server=SQLSERVER01;Database=FlamenetDB;Integrated Security=true;" />
      </appSettings>
    </configuration>
    

Step 2: Convert Data Access

Replace ADO Recordset code with ADO.NET:

Before (ASP/ADO):

<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open Application("ConnString")
Set rs = conn.Execute("SELECT * FROM Products WHERE Active = 1")
Do While Not rs.EOF
    Response.Write rs("ProductName") & "<br>"
    rs.MoveNext
Loop
rs.Close : conn.Close
%>

After (ASP.NET/ADO.NET):

string connStr = ConfigurationSettings.AppSettings["ConnectionString"];
using (SqlConnection conn = new SqlConnection(connStr))
{
    conn.Open();
    SqlCommand cmd = new SqlCommand(
        "SELECT ProductName FROM Products WHERE Active = 1", conn);
    using (SqlDataReader reader = cmd.ExecuteReader())
    {
        while (reader.Read())
        {
            Response.Write(reader["ProductName"] + "<br>");
        }
    }
}

Step 3: Replace COM Objects

Many COM objects used in ASP have .NET equivalents:

ASP (COM)ASP.NET (.NET)
Scripting.FileSystemObjectSystem.IO.File, System.IO.Directory
ADODB.ConnectionSystem.Data.SqlClient.SqlConnection
MSXML2.DOMDocumentSystem.Xml.XmlDocument
CDO.Message (email)System.Web.Mail.SmtpMail

Migration Tips

  • Migrate one page at a time — ASP and ASP.NET can run side-by-side
  • Replace On Error Resume Next with proper try/catch blocks
  • Use Server.HtmlEncode() (ASP.NET version) instead of manual escaping
  • Move connection strings out of code into web.config
  • Replace Session and Application objects carefully — ASP.NET Session is not shared with classic ASP Session
« Previous C# Language Primer
Next » ASP.NET Web Forms
More in .NET Framework
« Back to .NET Framework « Back to FDN
FlameNet Weekly: the best of the forum, freshest listings, top Q&A — delivered every Sunday.
13 members · 0 new today · 0 online now · 772 posts in last 24h