ASP.NET MVC has been discussed on this forum a few times. I'm about to do a large migration of several websites from classic ASP/ASP.NET WebForms to ASP.NET MVC and was wondering what kind of advice those of you with experience in both technologies have.
ASP。NET MVC已经在这个论坛上讨论过几次了。我将从经典的ASP/ASP中大量迁移几个网站。净WebForms ASP。我想知道你们中有这两种技术经验的人有什么建议。
What I have: a typical ASP.NET app with heavily coupled presentation/business logic, all sorts of messy ASP.NET-generated Javascript cruft, and so forth.
我有一个典型的ASP。NET应用程序具有强耦合的表示/业务逻辑,各种杂乱的ASP。net生成的Javascript cruft,等等。
What I want: clean ASP.NET MVC-generated agnostic markup. 'Nuff said.
我想要的是:清除ASP。净MVC-generated不可知论者的标记。足够地说。
Any pointers, tips, tricks, or gotchas to be aware of?
有什么要注意的指示、提示、技巧或陷阱吗?
Thanks!
谢谢!
4 个解决方案
#1
2
Any pointers, tips, tricks, or gotchas to be aware of?
有什么要注意的指示、提示、技巧或陷阱吗?
Well, I think you're probably a little ways away from thinking about tricks & gotchas :) As I'm sure you're aware, ASP.NET MVC is not some new version of ASP.NET, but a totally different paradigm from ASP.NET, you won't be migrating, you'll be initiating a brand new development effort to replace an existing system. So maybe you can get a leg up on determining requirements for the app, but the rest will probably re-built from scratch.
好吧,我想你可能离思考这些技巧和陷阱还有一段路要走。)我相信你已经意识到了,ASP。NET MVC并不是一些新的ASP版本。NET,但是与ASP完全不同。NET,您不会迁移,您将启动一个全新的开发工作来替换现有的系统。所以,也许你可以在确定应用程序的需求时获得一个优势,但是其余的可能会从头开始。
Based on the (very common) problems you described in your existing code base you should consider taking this opportunity to learn some of the current best practices in designing loosely coupled systems. This is easy to do because modern "best practices" are easy to understand and easy to practice, and there is enormous community support, and high quality, open source tooling to help in the process.
根据您在现有代码库中描述的(非常常见的)问题,您应该考虑利用这个机会学习设计松耦合系统的一些当前最佳实践。这很容易做到,因为现代的“最佳实践”易于理解和实践,并且有大量的社区支持和高质量的开源工具来帮助这个过程。
We are moving an ASP/ASP.NET application to ASP.NET MVC at this time as well, and this is the conclusion my preparatory research has led me to, anyway.
我们正在移动一个ASP/ASP。网络应用程序ASP。NET MVC也在这个时候,这是我的预备研究得出的结论。
Here is a post to links on using ASP.NET MVC, but I would start by reading this post. The post is about NHibernate (an ORM tool) on its surface but the discussion and the links are about getting the foundations right and is the result of preparing to port an ASP.NET site to MVC. Some of the reference architectures linked to in that post are based on ASP.NET MVC. Here is another post about NHibernate, but in the "Best Practices & Reference Applications" section most if not all of the reference applications listed are ASP.NET MVC applications also. Reference architectures can be extremely useful for quickly getting a feeling for how an optimal, maintainable ASP.NET MVC site might be designed.
这里有一个关于使用ASP的链接。NET MVC,但是我先读一下这篇文章。这篇文章是关于NHibernate(一个ORM工具)的,但是讨论和链接是关于建立正确的基础,并且是准备移植ASP的结果。网网站MVC。本文中链接的一些参考体系结构是基于ASP的。净MVC。下面是另一篇关于NHibernate的文章,但是在“最佳实践和参考应用程序”一节中,列出的大多数引用应用程序(如果不是全部的话)都是ASP。净MVC应用程序。参考体系结构对于快速了解最优的、可维护的ASP是非常有用的。可以设计NET MVC站点。
#2
3
Wow, I'm not sure we're talking migration here anymore - the difference is more like re-writing!
哇,我不确定我们在这里讨论的是迁移——区别更像是重写!
As others have also said, MVC is a whole new way to build web apps - most of your presentation code won't carry across.
正如其他人所说的那样,MVC是构建web应用程序的一种全新的方式——您的大多数演示代码都不会被执行。
However, if you are re-writing in MVC what you already have is a good prototype. Your problem is likely to be that it would be hard to do bit by bit - for instance MVC uses URL renaming out-of-the-box, making linking back and forth rather messy.
但是,如果您正在用MVC重写,那么您已经拥有了一个很好的原型。您的问题很可能是很难一点一点地做——例如MVC使用URL重命名的开箱即用,使链接前后相当混乱。
Another question would be why? Many of us have big sprawling legacy applications that we'd like to be in the latest technologies, but if your application is already working why switch?
另一个问题是为什么?我们中的许多人都有庞大的遗留应用程序,我们希望在最新的技术中使用它们,但是如果您的应用程序已经在工作,为什么要切换呢?
If I was looking at a new application right now MVC would be a very strong candidate, but there's no gain large enough to switching to it late in a project.
如果我现在正在查看一个新的应用程序,MVC将会是一个非常强大的候选者,但是没有足够大的空间可以在项目后期切换到它。
#3
1
WebForms can live with MVC controllers in the same app. By default, routing does not route requests for files that exist on disk. So you could start rewriting small parts of your site at a time to use the MVC pattern, and leave the rest of it using WebForms.
WebForms可以在同一个应用程序中与MVC控制器共存。默认情况下,路由不会路由对存在于磁盘上的文件的请求。因此,您可以一次开始重写站点的一小部分,以使用MVC模式,其余部分则使用WebForms。
#4
0
My opinion is that the two technologies are so different that if you have tightly coupled code in the original Web Form applications that the best approach is to start by picking one of them and converting it by creating a new ASP.NET MVC application and ripping out code into their respective layers. Which will put you on the trail of reuse for porting the other applications.
我的观点是,这两种技术是如此不同,如果您在原始的Web表单应用程序中有紧密耦合的代码,那么最好的方法就是从选择其中一种技术开始,并通过创建新的ASP来转换它。NET MVC应用程序,并将代码分离到各自的层中。这将使您走上重用的道路,以便移植其他应用程序。
#1
2
Any pointers, tips, tricks, or gotchas to be aware of?
有什么要注意的指示、提示、技巧或陷阱吗?
Well, I think you're probably a little ways away from thinking about tricks & gotchas :) As I'm sure you're aware, ASP.NET MVC is not some new version of ASP.NET, but a totally different paradigm from ASP.NET, you won't be migrating, you'll be initiating a brand new development effort to replace an existing system. So maybe you can get a leg up on determining requirements for the app, but the rest will probably re-built from scratch.
好吧,我想你可能离思考这些技巧和陷阱还有一段路要走。)我相信你已经意识到了,ASP。NET MVC并不是一些新的ASP版本。NET,但是与ASP完全不同。NET,您不会迁移,您将启动一个全新的开发工作来替换现有的系统。所以,也许你可以在确定应用程序的需求时获得一个优势,但是其余的可能会从头开始。
Based on the (very common) problems you described in your existing code base you should consider taking this opportunity to learn some of the current best practices in designing loosely coupled systems. This is easy to do because modern "best practices" are easy to understand and easy to practice, and there is enormous community support, and high quality, open source tooling to help in the process.
根据您在现有代码库中描述的(非常常见的)问题,您应该考虑利用这个机会学习设计松耦合系统的一些当前最佳实践。这很容易做到,因为现代的“最佳实践”易于理解和实践,并且有大量的社区支持和高质量的开源工具来帮助这个过程。
We are moving an ASP/ASP.NET application to ASP.NET MVC at this time as well, and this is the conclusion my preparatory research has led me to, anyway.
我们正在移动一个ASP/ASP。网络应用程序ASP。NET MVC也在这个时候,这是我的预备研究得出的结论。
Here is a post to links on using ASP.NET MVC, but I would start by reading this post. The post is about NHibernate (an ORM tool) on its surface but the discussion and the links are about getting the foundations right and is the result of preparing to port an ASP.NET site to MVC. Some of the reference architectures linked to in that post are based on ASP.NET MVC. Here is another post about NHibernate, but in the "Best Practices & Reference Applications" section most if not all of the reference applications listed are ASP.NET MVC applications also. Reference architectures can be extremely useful for quickly getting a feeling for how an optimal, maintainable ASP.NET MVC site might be designed.
这里有一个关于使用ASP的链接。NET MVC,但是我先读一下这篇文章。这篇文章是关于NHibernate(一个ORM工具)的,但是讨论和链接是关于建立正确的基础,并且是准备移植ASP的结果。网网站MVC。本文中链接的一些参考体系结构是基于ASP的。净MVC。下面是另一篇关于NHibernate的文章,但是在“最佳实践和参考应用程序”一节中,列出的大多数引用应用程序(如果不是全部的话)都是ASP。净MVC应用程序。参考体系结构对于快速了解最优的、可维护的ASP是非常有用的。可以设计NET MVC站点。
#2
3
Wow, I'm not sure we're talking migration here anymore - the difference is more like re-writing!
哇,我不确定我们在这里讨论的是迁移——区别更像是重写!
As others have also said, MVC is a whole new way to build web apps - most of your presentation code won't carry across.
正如其他人所说的那样,MVC是构建web应用程序的一种全新的方式——您的大多数演示代码都不会被执行。
However, if you are re-writing in MVC what you already have is a good prototype. Your problem is likely to be that it would be hard to do bit by bit - for instance MVC uses URL renaming out-of-the-box, making linking back and forth rather messy.
但是,如果您正在用MVC重写,那么您已经拥有了一个很好的原型。您的问题很可能是很难一点一点地做——例如MVC使用URL重命名的开箱即用,使链接前后相当混乱。
Another question would be why? Many of us have big sprawling legacy applications that we'd like to be in the latest technologies, but if your application is already working why switch?
另一个问题是为什么?我们中的许多人都有庞大的遗留应用程序,我们希望在最新的技术中使用它们,但是如果您的应用程序已经在工作,为什么要切换呢?
If I was looking at a new application right now MVC would be a very strong candidate, but there's no gain large enough to switching to it late in a project.
如果我现在正在查看一个新的应用程序,MVC将会是一个非常强大的候选者,但是没有足够大的空间可以在项目后期切换到它。
#3
1
WebForms can live with MVC controllers in the same app. By default, routing does not route requests for files that exist on disk. So you could start rewriting small parts of your site at a time to use the MVC pattern, and leave the rest of it using WebForms.
WebForms可以在同一个应用程序中与MVC控制器共存。默认情况下,路由不会路由对存在于磁盘上的文件的请求。因此,您可以一次开始重写站点的一小部分,以使用MVC模式,其余部分则使用WebForms。
#4
0
My opinion is that the two technologies are so different that if you have tightly coupled code in the original Web Form applications that the best approach is to start by picking one of them and converting it by creating a new ASP.NET MVC application and ripping out code into their respective layers. Which will put you on the trail of reuse for porting the other applications.
我的观点是,这两种技术是如此不同,如果您在原始的Web表单应用程序中有紧密耦合的代码,那么最好的方法就是从选择其中一种技术开始,并通过创建新的ASP来转换它。NET MVC应用程序,并将代码分离到各自的层中。这将使您走上重用的道路,以便移植其他应用程序。