Click here to Skip to main content
12,944,410 members (52,302 online)
Click here to Skip to main content
Add your own
alternative version


15 bookmarked
Posted 7 May 2005

Update Asp Code to Code

, 7 May 2005
Rate this:
Please Sign up or sign in to vote.
Update classic asp code to aspx

Sample Image - interface.jpg


We know Asp.Net does support ADO. But, if we simply change the file's postfix from ".asp" to ".aspx", always those files do not work. However it is not very hard to make them work. We can use some very simply rules to modify those files and make them work again. In this way can protect you company's investment in asp times. When you want to add new web capabilities, you can simply write them as classic Asp.Net Web Form, and don't need any session sharing bridge in the old asp code and the new Asp.Net code.

We make a automatic tool to do those jobs.

How to Update

(1)First change all file postfix in every page, from ".asp",".txt",".inc" to ".aspx". Both in file text itself and file postfix.

(2)Second use the mapping table as below, change Asp code.
set rs=Server.CreateObject("ADODB.RECORDSET")rs=Server.CreateObject("ADODB.RECORDSET")
If parameter="SET" Then parameter="GET" End IfIf parameter="SET" Then
End If
If CDate(****1)-CDate(****2)>0 ThenIf CDate(****1)>CDate(****2) Then
If session("LoginTime")="" Then
End If
If IsNothing(session("LoginTime")) Then
End If
If session("LoginTime").ToString()="" Then
End If
call CustomerSub("Parameter1")CustomerSub("Parameter1")
CustomerSub "Parameter1" CustomerSub("Parameter1")
End While

(3)Third Cut all customer define functions or subs to a VB Library project named WebLibrary's class named AspCommonFunction. Make all those functions or subs as  AspCommonFunction's shared function. import library System.Web for this project. Add five basic objects (Server,Application,Session,Request,Response) for each function as parameters. Add import library in every asp page begin place.
<%@ Import Namespace="WebLibrary" %>
Change function in asp page as below.
Function myfunction1()
End Function

In VB library:
Function myfunction1(Server,Application,Session,Request,Response)
End Function

In Asp code:
Function myfunction2(para1)
End Function

str=myfunction2("Test 2")
In VB library:
Function myfunction2(para1,Server,Application,Session,Request,Response)
End Function

In Asp code:
WebLibrary.AspCommonFunction.myfunction2("Test 2",Server,Application,Session,Request,Response)

Add parameter for some functions that need more shared parameters.
Function myfunction3(para1)
End Function

str=myfunction2("Test 2")
In VB library:
Function myfunction2(para1,Server,Application,Session,Request,Response,commonString)
End Function

In Asp code:
WebLibrary.AspCommonFunction.myfunction2("Test 2",Server,Application,Session,Request,Response,commonString)

Date function in asp code is used as getting current date. It does not supported in yet. So we define a new function named GetCurrentDate() to replace this function.

(4)We may define same customer function name in different asp files. So when we cut those codes from asp file to VB library, we should change the repeated function name to another name.

(5)In the end of each page that has included other pages, add this sentence
<% @Page Language="VB" Explicit="False" aspcompat="True"%>
To announce that this aspx page do not need Explicit parameters and can use asp Components.

Automatic Tools Introduce

(1)This tool can automatically change code from classic asp to aspx, and cut customer functions and subs to a VB Library. It also can deal with the Repeat Name in library.

(2)It also support a tool for manually add parameters for functions. It will according the "include" target in asp files to update all the text that use this function.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
China China
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionDownloading txt files Pin
sajana praveen6-Jun-08 22:47
membersajana praveen6-Jun-08 22:47 
QuestionFail to update from ASP to ASP.NET Pin
Lai-Hin Ho8-Jun-06 21:28
memberLai-Hin Ho8-Jun-06 21:28 
AnswerRe: Fail to update from ASP to ASP.NET Pin
dtab5-Sep-07 3:18
memberdtab5-Sep-07 3:18 
QuestionFail to update from ASP to ASP.NET Pin
Lai-Hin Ho8-Jun-06 18:53
memberLai-Hin Ho8-Jun-06 18:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170518.1 | Last Updated 8 May 2005
Article Copyright 2005 by kesmellon
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid