Combining ASP and ASP.NET projects together

G

Guest

Hi there

I have several bigger applications programmed with the old ASP (vbscript). A
lot of data is stored in the session object.

Now I have to extend the application with new functionality (-> complete new
part). My idea is to develop the new part in ASP.NET (C#) and leave the old
parts in the ASP environment. With this way I can migrate the old code step
by step into C# and I don't need to migrate the whole project in one step (->
I also have to migrate all test cases as well. And there are a lot of test
cases).

Is it possible to share data in the session object? I think this is not
possible because there are different session managers for the asp and the
asp.net session. Or am I wrong?

Any help is welcome.

Regards
Roger
 
A

Armando Canez

Right. You cannot share session objects because of different session
managers.

What I've done in similar situations is to have a "gateway page" between
both apps.

Something like this :

mypage.asp -> ASPGateway.asp -> ASPNETGateway.aspx -> DestinationPage.aspx

1. mypage.asp has a link like:
ASPGateway.asp?destination=DestinationPage.asp&optionalQueryStringElements=XXX

2. ASPGateway.asp adds all your session object Collection (works only on
simple datatypes) and dump them in to a HTML form, wich immediately posts
itself to ASPNETGateway.aspx

-- ASPGATEWAY.asp --
<HTML>
<BODY>
<FORM id="form1" action="ASPNETGateway.aspx?<% = Request.queryString %>"
method="post">
<input type="hidden" name="SessionObject_Item1" value = "<%=
Session("item1")%>">
<input type="hidden" name="SessionObject_item2" value = "<%=
Session("item2")%>">
<input type="hidden" name="SessionObject_item3" value = "<%=
Session("item3")%>">
<%
'include what is being sent in the request.Form
for each item in Request.Form
response.write "<input type=hidden name='" & item & "' value='" &
Request.Form(item) & "'>"
Next
%>
</FORM>
<script language="JavaScript" type="text/JavaScript">
form1.submit();
</script>
</BODY>
</HTML>
-- End of ASPGATEWAY.asp --

3. ASPNETGateway.aspx is an aspnet page. here you pick everything from the
ASPGATEWAY.asp post and put it on the aspnet session object (if its name
starts with "SessionObject_" )

-- ASPNETGATEWAY.aspx ---
<HTML>
<BODY>
<FORM id="form1" method="post">
<%
for each item in Request.Form
if item.toString().startsWith("SessionObject_") then
Session(item.toString().replace("SessionObject_", ""),
request.Form(item))
else
response.write "<input type=hidden name='" & item & "' value='" &
Request.Form(item) & "'>"
end if
Next
%>
</FORM>
<script language="JavaScript" type="text/JavaScript">
form1.action="<% = request.Querystring("destination") & "&" &
request.querystring("optionalQuerystring")%>"
form1.__VIEWSTATE.name='ignore';
form1.__VIEWSTATE.value='';
form1.submit();
</script>
</BODY>
</HTML>
-- ASPNETGATEWAY.aspx ---

That should help you pass session variables between asp and aspnet
applications. this would help also if you used forms authentication to
authenticate between apps.

(I'm doing this on my mind... there might be mistakes all over)

Hope it helps,

Armando Canez
 
A

Armando Canez

Could there be a better way? ... well... it depends...

Your ASP app could be easyly converted using a tool, depending on the size
and complexity of it, but there's no assurance it wouldn't have problems
after conversion.

Depending on the design of the app, maybe the way to go is to keep the ASP
app and use .NET web services for new or unavailable functionality in ASP.

Another way is to keep developing it in 100% ASP. Maybe the time and money
needed to rewrite that particular app is not worth it (if the customer is
not going to pay for it). Remember COBOL :)

And a third would be to try and design the new ASPNET pages in a sessionless
environment, and pass the ASP session variables in form hidden inputs

I was in your particular spot once, and I decided to do a COMPLETE rewrite
of my ASP app. It took A LOT of time and money, but it was the right
decision FOR MY CASE.

Armando Canez
 

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

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top