How do I convert legacy ASP applications to ASP.NE

2020-02-19 07:59发布

问题:

We have a large ASP (classic ASP) application and we would like to convert it to .NET in order to work on further releases. It makes no sense continuing to use ASP as it is obsolete, and we don't want to rewrite it from scratch (Joel Spolsky tells you why).

Is there a way to convert it from ASP to ASP.NET automatically?

回答1:

Well, I used to work for the company where all web apps were classic ASP. When decision was made to move to .NET we had to find a way to transform 168(!) web apps into this new framework. I tried all the tools available at the time to do this and all failed.

Best way is to build a new web server and start there from scratch, this way you can be sure that upgrade will happen fast and will work without any hick-ups because of old-new integration. You will be able to choose what functionality and visual appearances to keep and which one to change. Do not waste your time on automatic tools to upgrade your old ASP files/sites into NET platform. None so far have ever worked properly.

And on top of that if you have database on back end, you will run into problem with connection to it from web apps.



回答2:

Even if there are tools to convert between classic ASP and ASP.NET, they're not going to generate very good results: the two environments are just too fundamentally different. A quick Google turns up a few results, mostly of the "we'll have our guys in India do it" variety.

My advice would be not to touch your existing ASP code for now. The runtime environment will be supported by Microsoft for the foreseeable future, so there's no urgent need to migrate. Instead, start working on new functionality in ASP.NET: this way, you won't be held back by legacy concepts, and can use the new coolness afforded by the Framework (including stuff like ASP.NET MVC) in any way you see fit.

Of course, your new code will need to work with the existing ASP environment. Sharing session state between ASP and ASP.NET will most likely be one of your first requirements, but you'll soon identify more issues like that.

The 'right' solution for such issues will depend entirely on your current code and requirements: sometimes, you'll be able to wrap .NET code in a COM object for use by your ASP code, sometimes partial porting/migration may be the solution.

However, on average, the 'two worlds' approach should be entirely feasible, and allow you to develop exciting new features without having to worry about your legacy code.


December 2009 addition to original answer: Just came across the ASP Classic Compiler, which is an actively maintained VBscript compiler that converts classic ASP pages into code that runs natively on ASP.NET. It has several cool features, such as the ability to use it as a ASP.NET MVC custom ViewEngine, so despite its beta status, it would definitely seem worth keeping an eye on...



回答3:

Microsoft has an article up on MSDN that talks about Migrating ASP Pages to ASP.NET. They basically tell you to install .net on your computer/server and the transform one page at a time. ASP and ASP.NET can co-exist so can can rename each page to "aspx" as you go. You should note, however, that session state and application state are not shared between ASP and ASP.NET pages (See @mdb's answer for a workaround on that problem.)

There is also The ASP to ASP.NET Migration Assistant, but I'm not sure that project/program is still active. You can try it by downloading from this page:

http://www.asp.net/downloads/archived/migration-assistants/asp-to-aspnet/



回答4:

gmStudio is a comprehensive VB6/ASP/COM to .NET upgrade tool. It can read, analyze, interpret, rewrite and restructure (as C# or VB.NET) individual pages+includes or entire sites.

The technology has been in active development since 2007 and we have used it to help us rewrite sites ranging from a few hundred pages to 1000s of pages.

The tool is endorsed on MSDN here.

A (old) demo video is on ScreenCast here. (I really need to update this! Until then, please let me know if you want a live demo to see the latest.)

There is a more lot to tell, please contact us if you are intrested.

Disclaimer: I work for Great Migrations.