problem converting classic ASP to .NET

J

jason

i'm working on a gradual conversion of an ASP classic web site to
ASP.NET. a recent body of work involves adding a new asp page to the
existing site. i thought this would be a good opportunity to try this
"in place" conversion capability that .NET boasts.

the new aspx file, in order to function, will require many includes
from other ASP classic files. it was my impression that ASP.NET and ASP
classic would play well together in the same file, though? if this is
true, can some one tell me what causes the following error?

code from the top of "functions.asp" (the relevant part):

pathvariable = "/mypath/default.asp"

If rcdatabasetype = "MS SQL" Then
rctrue = 1
rcfalse = 0
Else
rctrue = True
rcfalse = False
End If

Function SQLFix(strSQL)
If Trim(strSQL) = "" Then
SQLFix = NULL
Else
SQLFix = Trim(strSQL)
End Function
End Function

code from the top of "testaspx.aspx" (the relevant part):

<%@ Page Language="vb" ContentType="text/html"
ResponseEncoding="iso-8859-1" CodeBehind="testaspx.aspx.vb"
AutoEventWireup="false" Inherits="myproject.testaspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/DT­D/xhtml1-
transitional.dtd">
<html>
<!-- InstanceBegin template="/templates/dotnet.dw­t.aspx"
codeOutsideHTMLIsLocked="false­" -->
<head>
<% Response.Buffer = True %>
<!--#include virtual="/pathstuff/constants.­asp"-->
<!--#include virtual="/pathstuff/functions.­asp"-->

but the compiler doesn't get past that bottom line of testaspx.aspx,
because it reports the following error when trying to compile
functions.asp (constants.asp is nothing but variable name declarations,
which is why i left it out of this question):

Compiler Error Message: BC30289: Statement cannot appear within a
method body. End of method assumed.

Source Error:

Line 10: End If
Line 11:
*Line 12: Function SQLFix(strSQL)
Line 13: If Trim(strSQL) = "" Then
Line 14: SQLFix = NULL

Source File:

C:\Inetpub\wwwroot\jason.rentc­licks.dev\classifieds\utilitie­s\functions.asp

Line: 12

this inclusion works just fine in the other 60 ASP classic pages on the
website. can someone point me in the right direction to figure out why
including the same files in an aspx file would fail?

thanks in advance,

jason
 
M

Marina

This is probably not going to work too well.

In ASP.NET, scripts that contain functions must be in <script
runat="server"> tags. And those that are just executable lines in <% %>
tags.

In general, I do not see an advantage to using ASP.NET, if you are still
going to be using the ASP model for how everything is structured.

The 2 technologies are not all that compatible - though some things may work
on both.

But since you are not taking advantage of anything .NET has to offer, I
would just continue doing everything in ASP. Whenever you port your site, it
should be more of a rewrite, so that you can do things in the new object
oriented way, etc.

From my experiencing in working on porting a web based app with hundreds of
asp pages, you really have to do it all at once, and just re do the way
things work. It's not something that lends itself to a gradual transition.

i'm working on a gradual conversion of an ASP classic web site to
ASP.NET. a recent body of work involves adding a new asp page to the
existing site. i thought this would be a good opportunity to try this
"in place" conversion capability that .NET boasts.

the new aspx file, in order to function, will require many includes
from other ASP classic files. it was my impression that ASP.NET and ASP
classic would play well together in the same file, though? if this is
true, can some one tell me what causes the following error?

code from the top of "functions.asp" (the relevant part):

pathvariable = "/mypath/default.asp"

If rcdatabasetype = "MS SQL" Then
rctrue = 1
rcfalse = 0
Else
rctrue = True
rcfalse = False
End If

Function SQLFix(strSQL)
If Trim(strSQL) = "" Then
SQLFix = NULL
Else
SQLFix = Trim(strSQL)
End Function
End Function

code from the top of "testaspx.aspx" (the relevant part):

<%@ Page Language="vb" ContentType="text/html"
ResponseEncoding="iso-8859-1" CodeBehind="testaspx.aspx.vb"
AutoEventWireup="false" Inherits="myproject.testaspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/DT­D/xhtml1-
transitional.dtd">
<html>
<!-- InstanceBegin template="/templates/dotnet.dw­t.aspx"
codeOutsideHTMLIsLocked="false­" -->
<head>
<% Response.Buffer = True %>
<!--#include virtual="/pathstuff/constants.­asp"-->
<!--#include virtual="/pathstuff/functions.­asp"-->

but the compiler doesn't get past that bottom line of testaspx.aspx,
because it reports the following error when trying to compile
functions.asp (constants.asp is nothing but variable name declarations,
which is why i left it out of this question):

Compiler Error Message: BC30289: Statement cannot appear within a
method body. End of method assumed.

Source Error:

Line 10: End If
Line 11:
*Line 12: Function SQLFix(strSQL)
Line 13: If Trim(strSQL) = "" Then
Line 14: SQLFix = NULL

Source File:

C:\Inetpub\wwwroot\jason.rentc­licks.dev\classifieds\utilitie­s\functions.asp

Line: 12

this inclusion works just fine in the other 60 ASP classic pages on the
website. can someone point me in the right direction to figure out why
including the same files in an aspx file would fail?

thanks in advance,

jason
 
J

jason

ahh, so this whole theory of "in place" conversion isn't all it's
cracked up to be? i appreciate the commentary!

obviously there's tons of .NET things we eventuallyl want to take
advantage of. but yeah, perhaps piece by piece isn't the way to go
about it.

on this topic, i am writing some .NET middleware objects to retrieve
data. eventually ASP.NET pages will be interacting with these
middleware objects, but in the meantime, how would you recommend
handing a set of data from the .NET objects to the ASP classic? the ASP
classic can't do anything with an SQLDataReader. will i have to create
an ASP classic interface that hands off an old ADO style recordset? is
that even possible in a .NET object, or will it insist on using ADO.NET
objects?

thanks for any help

jason
 
E

Elliot M. Rodriguez

It is possible to work with the pre-.NET ADO data access objects (2.7
and older). But this incorporates an additional layer (COM Interop),
and can adversely affect application performance.

In addition, it is also possible to write your .NET components so they
are COM compatible (and thereby instanced using the traditional progid
method in ASP) by registering them for COM Interop (which will create
registry entries and a callable type library)... but this is also slow.

Youre better off doing it all in one shot, like Marina suggested.
 
J

jason

sadly not an option in my current project environment.

i have already made my .NET objects available through COM Interop
successfully. that is how the ASP classic has been making use of the
objects before now.

but up until this point, all of the data has been simple properties
that are easily converted between the two. i'm curious about a more
complex data element, like an SqlDataReader in my .NET object. even if
my object is registered for COM Interop, can the ASP classic get at
that SqlDataReader and interact with it in a meaningful way? (if i were
still at the office, i would simply give it a shot, but i'm on
vacation, yay!)

i'm guessing not, so i need to look into the ability to add a pre .NET
ADO object to the .NET class library, so that when classic ASP
instantiates it through COM Interop, it can actually use the data
access object? or is there someway that it can make use of the
SqlDataReader?

thanks for the comments, btw. and yeah, if i could shut down
development for a good few months to convert the whole thing in one
fell swoop, i definitely would :)

jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top