将Web窗体迁移到ASP.NET Core MVC的最佳实践 [英] Best practise to migrate Web Forms to ASP.NET Core MVC

查看:90
本文介绍了将Web窗体迁移到ASP.NET Core MVC的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将项目从经典的ASP.Net Web窗体迁移到ASP.NET MVC.

I am trying to migrate a project from classic ASP.Net Web Forms to ASP.NET MVC.

虽然我已阅读 http://www.codeproject.com/Articles/38778/ASP-NET-WebForms-and-ASP-NET-MVC-in-Harmony .我对如何完成代码结构,库和路由有一个基本的想法.

While I have read through http://www.codeproject.com/Articles/38778/ASP-NET-WebForms-and-ASP-NET-MVC-in-Harmony. I have a basic idea on how the code structure, libraries and routing should be done.

供您参考,我现有项目的范围约为400页和300张表.

For your information, the scope of my existing project is around 400 pages and 300 tables.

在我的头顶上,我有两种方法:

On top of my head I have two approaches:

  1. 从头开始,重写整个系统-显然,这需要大量的工作并且需要很长时间.在现有系统上进行的任何更改都需要对新系统进行重复的更改.
  2. 每个迁移页面-我仍然有一个完整的核心库(用于访问数据库),并逐步迁移页面.为此,我假设有两个同时运行的核心库(新的和旧的),并且不同的页面连接到其中一个.
  1. Start from stretch, rewriting the whole system - Obviously this would require intensive work and take a long time. Any change made on existing system would need a duplicate change made to the new system.
  2. Migrate the page one each - I still have a rebuild the entire core library (for accessing db), and get the page migrated one by one. For this I would assume to have two core libraries (new and old) running simultaneously with different pages connect to one of those.

会有人有类似的经验并建议适当的开始方式吗?

Would anyone have similar experience and advise a proper way to start?

对于这次彻底的改造,我还可以针对最新技术-.NET Core和MVC6,通过采用这些技术,我是否会拥有更多优势,或者我需要解决一些障碍?

For this complete revamp I may also target at the latest technology - .NET Core and MVC6, by taking these would I have extra advantage, or some blockages I would have to take care of?

任何建议和意见都值得赞赏.干杯.

Any suggestion and opinions are appreciated. Cheers.

推荐答案

Microsoft在这个问题上有点嘘",但WebForms引擎可能永远不会进入ASP.NET Core..有人可能会认为MS正在等待查看社区是否在要求使用端口,但我认为他们正在尝试不经意地杀死它(不像Silverlight).

Microsoft is a bit hush hush on the subject but the WebForms engine is probably never going to make its way to ASP.NET Core. One might think that MS is waiting to see if the community is calling for a port, but I think they're trying to kill it discretely (not like Silverlight).

为什么?因为从长远来看,这被证明是一个坏主意,起初易于使用,但是掌握起来极为复杂(由于视图状态和页面生命周期),并且倾向于让普通开发人员构建非常繁琐的应用程序(法语,例如蒸汽工厂).而且,它非常不适合现代Web开发(Ajax,单元测试,IoC).他们试图通过一些调整来修复它,但是整个体系结构只是不适应这种情况.比较而言,MVC是一种享受!

Why? Because it proved to be a bad good idea on the long run, easy to use at first, but extremely complex to master (because of viewstate and page lifecycle), with a tendency to allow average developers to build very tedious application (in french we say steam factories). Also it was very poorly adapted to modern web development (Ajax, unit testing, IoC). They tried to fix it with a couple of tweaks, but the overall architecture is just not adapted to this kind of things. MVC is a treat in comparison!

要回答您的问题,实际上不可能将WebForms迁移到MVC,因为它们是完全不同的体系结构,当然,该体系结构是应用程序所基于的,因此,如果进行更改,则最好重写从头开始.

To answer your question, it's not really possible to migrate WebForms to MVC, because those are quite different architectures, and of course the architecture is what an application sits on top on, so if you change it, you might as well rewrite it from scratch.

如果您的应用程序分为几层(业务,数据访问,UI),则可以为您带来很多帮助.如果不是这种情况,则可以从此开始,将UI项目与其余项目正确分开.然后,您将 just 必须重写ASP.NET项目,而不是其余部分.

What can help you a lot is if your app is divided in tiers (business, data access, UI). If it's not the case, you could start by doing this, properly separating the UI project from the rest. Then you would just have to rewrite the ASP.NET project and not the rest.

这篇关于将Web窗体迁移到ASP.NET Core MVC的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆