简体   繁体   中英

Classic ASP in ASP.NET MVC (C#)

I have an application that I want to (eventually) convert to ASP.NET MVC. I want to do an all out service upgrade (to ASP.NET) but want to use current asp stuff to run the current functionality so I can upgrade small pieces while making incremental upgrades to the new framework. This site is heavily dependent on a VB6 DLL that is not very mature, so we will also want to upgrade this eventually too, potentially replacing the current functionality with web services. Is there a quick fix or is this task a 3 month + task? Also, I am sure it has been thought of before, the beauty of the MVC is that I would think there is a way to tackle this, though I am unsure of where to start. What would be the quickest way to convert this application (in 40 or so hours), where I can just make small configuration changes and have this working in ASP.NET MVC?

The short answer is... You can't. The differences between classic asp and asp.net are fairly drastic not just in syntax but in overall design. MVC is not just a similar implementation to classic asp although it may look that way. Any conversion will take time, thought and effort to get it completely working.

The good news though, is that you can run them SxS so you can actually have classic asp code running under a site that is setup as an ASP.NET or ASP.NET MVC site. So with some duct tape you can peice together your upgraded solution part by part.

Rewrite your VB6 DLL as a COM callable .NET assembly. Then, you can reference it both from ASP and ASP.NET.

Hopefully, most of the heavy lifting is in the VB6 DLLs. If so, you can then start migrating pages over to ASP.NET MVC as you want. You have to watch out for page-to-page communication - things like Session and Cookies. Cookies will pretty much work as is, but you'll need to move Session to something shareable between MVC and ASP like Sql Server. Unfortunately, that requires rewriting your Session calls in ASP to something else (possibly a COM wrapper around a .NET component again). Search and replace should do the trick, though.

As for the timeline and amount of work this entails - that's pretty context dependent on the amount of spaghetti in your existing app, how much logic is in the DLL vs. ASP, and how many pages you're migrating.

I don't think 40 hours is a reasonable amount of time to get up to speed with .NET, MVC, and rewrite - though I think 2-3 months could be.

I have been working on a similar project for quite some time now; We had a classic ASP app and wanted to move it to ASP.Net (using WebForms). We do it a piece at a time, if we are adding a new page we do it in .Net and just redirect the user between the .asp files and .aspx files. Working with MVC should be no different.

The biggest issue we ran into was security; The site required a log in and the session is of course not shared between the two. We handled this by persisting the bits of session we cared about to a table in a database and passing a GUID through the query string (we only do this one time at login, then delete the record from the database to reduce security risks).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM