Click here to Skip to main content
15,886,606 members
Articles / Web Development / IIS
Article

Update Asp Code to Asp.net Code

Rate me:
Please Sign up or sign in to vote.
1.83/5 (7 votes)
7 May 20053 min read 47.9K   784   15   4
Update classic asp code to aspx

Sample Image - interface.jpg

Introduction

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.
ASPASP.net
set rs=Server.CreateObject("ADODB.RECORDSET")rs=Server.CreateObject("ADODB.RECORDSET")
Rs("ColumnID")Rs.Fields("ColumnID").value
<%=parameter%><%Response.Write(parameter)%>
If parameter="SET" Then parameter="GET" End IfIf parameter="SET" Then
    parameter="GET"
End If
IsNullIsDBNull
InEmptyIsNothing
If CDate(****1)-CDate(****2)>0 ThenIf CDate(****1)>CDate(****2) Then
If session("LoginTime")="" Then
   session("LoginTime")=0
End If
If IsNothing(session("LoginTime")) Then
    session("LoginTime")=""
End If
If session("LoginTime").ToString()="" Then
   session("LoginTime")=0
End If
call CustomerSub("Parameter1")CustomerSub("Parameter1")
CustomerSub "Parameter1" CustomerSub("Parameter1")
While(....)
Wend
While(....)
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.
ASPASP.net
Function myfunction1()
        myfunction1="Test"
End Function

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

In Asp code:
WebLibrary.AspCommonFunction.myfunction1(Server,Application,Session,Request,Response)
Function myfunction2(para1)
      myfunction2=para1
End Function

str=myfunction2("Test 2")
In VB library:
Function myfunction2(para1,Server,Application,Session,Request,Response)
      myfunction2=para1
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.
ASPASP.net
Function myfunction3(para1)
      myfunction2=commonString+para1
End Function

str=myfunction2("Test 2")
In VB library:
Function myfunction2(para1,Server,Application,Session,Request,Response,commonString)
      myfunction2=commonString+para1
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 Asp.net 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.
Image 2

(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.
 

Image 3

License

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


Written By
Web Developer
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionDownloading txt files Pin
sajana praveen6-Jun-08 22:47
sajana praveen6-Jun-08 22:47 
QuestionFail to update from ASP to ASP.NET Pin
Lai-Hin Ho8-Jun-06 21:28
Lai-Hin Ho8-Jun-06 21:28 
AnswerRe: Fail to update from ASP to ASP.NET Pin
dtab5-Sep-07 3:18
dtab5-Sep-07 3:18 
QuestionFail to update from ASP to ASP.NET Pin
Lai-Hin Ho8-Jun-06 18:53
Lai-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.