简体   繁体   English

将网站从asp.net迁移到asp.net mvc

[英]migrating website from asp.net to asp.net mvc

进行此转换时是否有任何高级别的最佳做法?

I do not believe there is a vast experience gathered on this matter. 我不相信在这件事上收集了大量的经验。

Some people are migrating their projects, the others are staying with WebForms. 有些人正在迁移他们的项目,其他人正在使用WebForms。 Not every project can be migrated to MVC in that way that you can still speak of migration and not of complete rewriting of several layers. 并非每个项目都可以以这种方式迁移到MVC,您仍然可以说迁移而不是完全重写几个层。 Not all projects need to be migrated. 并非所有项目都需要迁移。

If I were to start that kind of migration, the foremost thing I would do is to try to understand whether it makes sense anyway for this particular project to be migrated. 如果我要开始那种迁移,我要做的最重要的事情就是试着了解这个特定项目是否有意义迁移。 MVC is very good for web sites . MVC非常适合网站 Web applications with very complex UI (lots of interdependent controls) will be very difficult to migrate. 具有非常复杂的UI(许多相互依赖的控件)的Web应用程序将很难迁移。 Since now you won't be able to rely on event-model and will have to manually code lots of JavaScript to interconnect controls (enable/disable, repopulate, show/hide etc.). 从现在开始,您将无法依赖事件模型,并且必须手动编写大量JavaScript来互连控件(启用/禁用,重新填充,显示/隐藏等)。 Are you ready for that? 你准备好了吗?

If however you decide to go on, the first thing I would try is to gather the code scattered all over your project including the code-behind classes to unify it and split into two categories: business rules and controller decisions. 如果你决定继续,我要尝试的第一件事就是收集分散在整个项目中的代码,包括代码隐藏类,以统一它并分为两类:业务规则和控制器决策。 Many WebForms projects are really a bad mess with no separations of concerns but just one big monolithic piece of code. 许多WebForms项目实际上是一个糟糕的混乱,没有任何分离的问题,而只是一个巨大的单片代码。 If you manage to split it into layers (data access, business rules, controller logic) you win. 如果您设法将其拆分为多个层(数据访问,业务规则,控制器逻辑),您就赢了。 Otherwise the enterprise is doomed. 否则企业就注定了。

If you already have your Model layer (services, models, repositories, etc.) in a separate project, your web site would not be that hard to move. 如果您已在单独的项目中拥有模型层(服务,模型,存储库等),那么您的网站就不会那么难移动。 But it will still require some reworking for the interface... you will have to create Views, ViewModels, Controllers, ModelBinders, etc. 但它仍然需要对界面进行一些重新设计......你将不得不创建Views,ViewModels,Controllers,ModelBinders等。

If your project is not currently set up using an n-tier approach, I would recommend moving towards that before you move the whole site to MVC. 如果你的项目目前没有使用n层方法设置,我建议将整个站点移动到MVC 之前转向该项目。 It will make the move to MVC all that much easier, without having to redo the entire project at once. 它将使MVC的移动变得更加容易,而无需立即重做整个项目。

Does it all really need to be converted would be my number one question here? 这一切真的需要转换是我的头号问题吗? MVC and Web-Forms can live side-by-side in the same app, so could new pages/ sections simply be developed using MVC if that's the route you want? MVC和Web表单可以在同一个应用程序中并存,因此如果您想要的路径,可以使用MVC简单地开发新的页面/部分吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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