Marco Trova's weblog

Italian .NET life

Execute ASP code from ASP.NET: my weird idea results

Last week I wrote about my simple weird idea on executing ASP in an environment built with a VB COM object that execute a asp file through an Asp.net HttpHandler.

I added the necessary basic features to execute the old-classic DNA sample application: FMStocks 2000 SP2.

The asp extension is mapped on then aspnet_isapi.dll, a simple entry on my web.config, a simple HttpHandler receives all requests for asp files, passing Form, QueryString, ServerVariables, Session and Cookies collections and, after the execution of ASP code, reading some of them modified by ASP execution.

Most of the problems I have encountered were in parsing ASP code adapting it to the new execution environment: some words such as Clear, End and Write are reserved words in VB6.

I found that executing ASP code through my code is only about 5-10% slower than in normal ASP mode, but the "Average time to last byte" was about 200% slower, due the simulated environment.

I have demonstrated myself that executing and sharing state (Session and Cookies) between ASP and ASP.NET is possible, however my solution is not ready for a production site. I did not developed all possible ASP objects nor tested the solution with a lot of ASP applications.

But I am satisfied of the work done.

Depending of the feedback I would like share the code..

Comments

Jon Galloway said:

This is great news! I've been working on a large intranet with 5000+ ASP pages that is slowly being migrated to ASP.NET using frames and database session storage, and it's been a huge pain in the neck. This would be a really clean solution.
# April 15, 2004 12:45 PM

Marco Trova said:

I was thinking I am the only one with these kind of problems.. ;-)

I would do some documentation to share decisions made and discuss future enhancements.
# April 15, 2004 2:35 PM

Bertrand Le Roy said:

Interesting. I had the exact same idea some time ago.

Check this out:
http://www.dotnetguru.org/us/articles/ASP2ASPNET/ASP2ASPNET.html

And in french:
http://www.dotnetguru.org/article.php?sid=142

Source code included there!

I'd very much like to see your source code as it seems to be a little more advanced than mine, which was just a proof of concept.

bleroy (at) microsoft.com (btw, I'm a dev in the ASP.NET team)
# April 15, 2004 3:56 PM

Marco Trova said:

bleroy, I've read your article and my code is just a proof of concept, too.

I have prefered to remain in a unmanaged space to execute ASP code, to increase performance and to eliminate all interop problems: only filename path of the page requested and returned HTML code are passed. But I can't react to events like Response.Redirect in timely manner, until the code esecution complete (I have simulated it through a META tag). In contrast, your method gives full control on flow of the esecution directly in ASP.NET.

Default method trick was used to implement defautl methos of ASP objects, but I haven't implement collection of collection found in Cookies collection: example Request.Cookies("ID")("Name").

I have upload my source code (directly from dev machine, so sorry about my primitive VB programming) on: http://www.dotmark.net/ASPEE/download/aspee00.zip

Hope discussion and sharing of ideas will start..
# April 15, 2004 5:43 PM

Bertrand Le Roy said:

Interesting. I like what you've done with output buffering. It removes the main bottleneck by keeping it unmanaged until the very end of the page treatment. You have a few side-effects, of course (redirect being one, but I suppose turning buffering on or off must not work either), but you could probably work around this by just turning back to managed code in these exceptional circumstances. I mean, Redirect could very well be a call to the managed Redirect, like in my code, and Response.Flush could send the existing buffer to the managed response and flush... So the correct approach is probably a mix of your code and mine.

What did you think of the idea to call classic ASP code à la Web Service, with a proxy class?

Yeah, let's share ideas and code. As far as I'm concerned, I have very limited development time to spend on this, but you can use what you want from my code if you find interesting stuff in there. And I have time for discussion. And if I can assist in any other way...
# April 16, 2004 3:45 PM

Marco Trova said:

Yes, probably the right approach is a mix of the two ways.. I admit I prefer a pure managed approach, like yours..

What do you mean with the proxy class? A web service to off-load execution of the asp code?

Regarding sharing, seems we are in three interested in this weird idea.. ;-)


# April 16, 2004 5:04 PM

Bertrand Le Roy said:

Read my paper. It's at the end. It's a proxy class that looks like those we use for web-services, except that it doesn't execute a web service but a classic-ASP function, from managed code. Very useful in a migration scenario where you have a lot of legacy non-UI code written in classic ASP classes.
# April 16, 2004 5:38 PM

Kiliman said:

Hi Marco,

Your “proof of concept” is interesting. When I was working on CassiniEx, I wanted to see if I could get it to host Classic ASP applications as well. I tried doing it a little differently by actually loading the ASP ISAPI dll. However, it is so tightly integrated with IIS and COM+ that I abandoned that idea.

Although your current code will work for basic ASP pages, there is one area it doesn’t handle. The problem is that it won’t handle components hosted in COM+. A lot of complex ASP applications will rely on components that are running in COM+. These components need access to the COM+ ContextObject. That’s a lot harder than running some VBScript in the scripting host. That’s the main reason I gave up on running ASP pages.

For a lot of people, your code will meet their needs.

Kiliman
# April 19, 2004 9:23 AM

Bertrand Le Roy said:

Kiliman: this is a very good point, but I don't think exposing the context to COM+ hosted components is impossible. For example, if you relay the Server.CreateObject method to the managed part, you should probably get the ASP.NET context. Of course, this would hurt performance. But perhaps it is possible to set the context object another way. I could speak to some COM+ people here.
# April 19, 2004 3:10 PM

TrackBack said:

^_^,Pretty Good!
# April 9, 2005 11:28 PM

ragothaman said:

hi..

how to run pure asp coding in asp.net

# September 21, 2007 8:11 AM

Pavan Said said:

Very Interesting.........

# December 13, 2007 8:30 AM

Pavan Said said:

Is Migration Required ??,

why we go for to Develop Communication btn

ASP and ASP.NET....

# December 13, 2007 8:42 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)