简体   繁体   中英

Is it at all possible to migrate ASP.NET ASPX solution to ASP.NET Core 2.0?

I want to migrate my asp.net (UI ASPX pages WebForms) application to ASP.NET Core 2. By some search I found out aspx is not supported in .net core. If this is true(anyone has exact documentation for this?) how should anyone proceed to convert from pure asp.net aspx project to asp.net core 2.0?

I used portable analyzer tool but it is confusing to just give every.dll file and get report which is more confusing.

Please give valid Microsoft document if possible.

It all depends on what you mean by "migrate". As mentioned in the comments to your question, ASP.NET Core does not support web forms so there isn't any way to just automatically convert an a Web Forms website to an ASP.NET Core website.

That said, it is possible to make the migration. I have been working to do just that for a very large web forms based website that I want to convert to ASP.NET Core. If you are serious about making the journey, then here is some info that will probably help you.

The general architecture of ASP.NET Core is based on MVC so it's much more similar to ASP.NET MVC than ASP.NET Web Forms. So you will end up rewriting pretty much all of your UI code using some derivative of a MVC pattern. Instead of master pages you will be using layouts. Instead of server controls you will be using tag helpers. Instead of user controls you will be using partials and view components. Instead of code behinds you will be using controllers and view models. Etc.

It's worth noting that there is still an http context object, request object and response object and they are extremely similar to the analogous objects in web forms. So that helps with the conversion.

Also to make the conversion process easier, you can build an ASP.NET Core web application that targets the full framework. This means that you will have access to most everything you are use to in the full framework except anything in the System.Web namespace. Targeting the Full framework does mean that your new website will only run on windows. But if you can live with that (at least for now) it will make the conversion process easier for you.

If, in your old website, you broke out a bunch of the functionality into class libraries, that will make your life easier. You should be able to bring those class libraries over to the new website unchanged and reference them from the ASP.NET Core website and they will most likely work fine provided they don't reference System.Web. Any code that does reference System.Web will need to be modified to use the new analogous objects or UI approaches.

So in the end, you may be able to bring over your data models, data access code, business objects, and business logic without too much hassle. But you will have to do a total rewrite of your UI related code. That's the journey I'm on and it's not as hard as you might think, at least not once you get up to speed with ASP.NET Core in the first place. Go get `em!

I found an article claiming that it's possible somehow. As you know it's not easy to migrate entire project from WebForm to.Net Core instantly. So what if I be able to have my web form pages working on production and at the same time start to convert pages one by one gradually? I mean there are the combination of two approaches at the same project.

It's the idea that an open source named DotVVM proposes. You have your ASP.Net web form pages and merely install DotVVM through Nuget. DotVVM supports both approaches. DotVVM contains similar controls like GridView, Repeater, FileUpload and more, you need to know about DotVVM syntax though.

DotVVM can run side-by-side with other ASP.NET frameworks (Web Forms, MVC, Razor Pages)

it's claimed that:

If the business layer is separated properly, rewrite on one page takes about 1 hour in average.

After a few months (if your project is large), when all the ASPX pages are rewritten in DotVVM, you will be able to create a new ASP.NET Core project, move all DotVVM pages and viewmodels into it and use them with .NET Core. The syntax of DotVVM is the same on both platforms.

Here you can see five steps needed for the migration.

You can transfer all your business logic, models and even some controller methods (You just need to adjust those ActionResult to IActionResult). If you're using Ninject (for ASP.NET Framework IOS), you just need to register them to your Startup.cs. Basically, what I'm trying to say, you need to create a new application under .NET Core. It would be changes in the actual project solution, but your actual business flow won't be different. I hope this helps you.

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