My Account Subscribe Help About
Sign In | Register FREE
Friday, April 10, 2026
Ceasefire or no ceasefire, the Middle East's reshuffling is not yet doneMan arrested after baby girl dies from dog biteMan jailed for killing abused wife who jumped from bridgeMelania Trump denies ties to Jeffrey Epstein and urges hearing for survivorsSimple guide: How the Iran war is affecting the cost of holidays, food and clothesMen behind 'Tripadvisor for people smugglers' jailed for 19 yearsIreland protesters willing to 'close the country' over fuel costsEU fingerprint and photo travel rules come into forceIran conflict will define us for a generation, says PMBafta fell short in duty of care when racial slur was shouted, review findsExtra £5m pledged for patrolling places of worship in London and ManchesterLebanon says ceasefire must be in place before Israel talks'Endless fears': Even if fighting stops, the damage to Iran's children will endureHow many ships are crossing the Strait of Hormuz?Want to help garden birds? Don't feed them in warmer months, says RSPBCan stats help you find the Grand National winner?Ten cases a day - 'blitz courts' could tackle the Crown Court backlogThis coat cost $248 in illegal tariffs. Will he ever get the money back?From a smuggled harmonica to Artemis' playlist - the history of music in spaceLava soars into air as Hawaii's Kilauea volcano erupts againWeekly quiz: What might have made Paddington panic about his marmalade?LeBron and Bronny James record first son-to-father assist in NBA history'I was in a slump - now my art is in Billie Eilish's house'Labrinth not involved in Euphoria's third seasonWhite House staff told not to place bets on prediction marketsRussia and Ukraine agree to Orthodox Easter truceBBC News appIs Defence Secretary Pete Hegseth waging a holy war against Iran?Defence secretary interview on Russian submarine operationWhat version of Tyson Fury will turn up this weekend?
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
« Back to .NET Framework « Back to FDN