I'm doing some maintenance on a classic ASP application for my client, and as I'm looking through the ASP, the following question comes to mind - would it be easier to convert a classic ASP app to ASP.NET MVC or ASP.NET WebForms?
我正在为我的客户端做一些经典ASP应用程序的维护,当我正在浏览ASP时,会想到以下问题 - 将经典ASP应用程序转换为ASP.NET MVC或ASP会更容易。 NET WebForms?
In many ways, it appears that at least the HTML of ASP might be easier to convert to MVC than it would be to rip out the HTML chunks and turn them into ASP.NET controls, repeaters, datagrids, etc. Plus having to add in handling and logic for ViewState, etc. might be added work.
在许多方面,似乎至少ASP的HTML可能更容易转换为MVC,而不是撕掉HTML块并将它们转换为ASP.NET控件,转发器,数据网格等。另外还需要添加可以添加ViewState等的处理和逻辑。
I don't think my client will be requesting any upgrade like this, so this is just theoretical.
我不认为我的客户会请求任何这样的升级,所以这只是理论上的。
Let's assume that this ASP code is written very well (which isn't always true of course) so really the question is, will a best-case-well-designed ASP site migrate better to MVC than WebForms?
让我们假设这个ASP代码编写得非常好(当然并不总是这样),所以问题是,一个设计得最好的ASP站点是否会比WebForms更好地迁移到MVC?
(Note that I'm very new to ASP.NET MVC, so I might be missing something crucial here).
(请注意,我对ASP.NET MVC很新,所以我可能会遗漏一些关键的东西)。
10 个解决方案
#1
7
It depends a lot on how the classic asp app is structured.
这很大程度上取决于经典asp应用程序的结构。
The server tag mixed in with HTML is similar to asp.net mvc but MVC is not as messy (or not supposed to be). You might be able to move the classic asp presentation code to a MVC view easier than to a web form. Also classic asp apps were usually developed with the statelessness of the web in mind. There probably is not anything in your classic asp that matches postabacks or viewstate. Classic ASP also uses normal html elements as opposed to asp.net webform controls. In these respects it matches MVC a lot closer than webforms.
与HTML混合的服务器标签类似于asp.net mvc,但MVC并不是那么混乱(或者不应该是)。您可以将经典的asp演示代码移动到MVC视图比移动Web表单更容易。此外,经典的asp应用程序通常是在考虑到Web的无状态的情况下开发的。你的经典asp中可能没有任何东西与postabacks或viewstate相匹配。经典ASP还使用普通的html元素而不是asp.net webform控件。在这些方面,它比MVforms更接近MVC。
If you do not know asp.net webforms or asp.net mvc I would say MVC is the way to go.
如果你不知道asp.net webforms或asp.net mvc我会说MVC是要走的路。
If you know webforms very well and don't know much about MVC I would say webforms is the way to go.
如果你非常了解webforms并且对MVC知之甚少,我会说webforms是要走的路。
But, if your client for some reason does want a redevelopment of the site I would say go with MVC. It's always nice to have a client pay for part of your experience development as long as you can deliver.
但是,如果您的客户出于某种原因想要重新开发该网站,我会说与MVC一起去。只要您能够交付,让客户支付部分经验开发总是很好的。
On another note I'm always taken aback when I come across a client who wants me to do work on their classic asp site. In every single case the site is a mess. The worse part is that they are usually filled with huge security holes.
另一方面,当我遇到一位希望我在他们的经典asp网站上工作的客户时,我总是吃惊。在每一个案例中,网站都是一团糟。更糟糕的是,它们通常充满了巨大的安全漏洞。
#2
4
I think in a lot of cases it could be easier to convert to MVC than Webforms. Most classic ASP apps demonstrate very little separation of concerns so the biggest task is probably exactly that, seperating out the logic into data access, business logic, business entities and UI components. In doing that it could well be easier to convert the inline ASP code to a view, the business logic into controllers and the business entities into the model.
我认为在很多情况下,转换为MVC比Webforms更容易。大多数经典ASP应用程序几乎没有关注点分离,因此最大的任务可能就是将数据访问,业务逻辑,业务实体和UI组件分离出来。在这样做时,可以更容易地将内联ASP代码转换为视图,将业务逻辑转换为控制器,将业务实体转换为模型。
#3
4
I don't think one would be easier to convert then the other.
我不认为一个人比其他人更容易转换。
You can code ASP.NET almost the same as you code ASP if you wanted putting a few crucial elements in the codebehind that you could access in the aspx. No databinding, no gridview and no repeater. The view state is there to help you can is easy to figure out, it is not necessary to use it if you don't want and can be turned off in the web.config and turned on with a page attribute. Web forms also have an AspCompat mode which allows access to Request and Response objects or asp, which will allow for page by page conversion if desired.
如果你想在aspx中访问代码隐藏中的几个关键元素,你可以编写几乎与代码ASP相同的ASP.NET代码。没有数据绑定,没有gridview,也没有转发器。视图状态可以帮助您轻松搞清楚,如果您不想要它就没有必要使用它,可以在web.config中关闭并打开页面属性。 Web表单还具有AspCompat模式,允许访问Request和Response对象或asp,如果需要,可以进行逐页转换。
As for MVC.net, the method for displaying the HTML is quite similar. That in my opinion is where the similarities end. You would still need to separate out all you logic into the MVC model.
至于MVC.net,显示HTML的方法非常相似。在我看来,这就是相似之处的结束。您仍然需要将所有逻辑分离到MVC模型中。
Coming from ASP and going to Web.Form and now MVC.Net I can tell you that WebForms were a little annoying/frustrating to learn, with 90% of the MS tutorials teaching you the worst possible habits IE (SQL connections on the page, dragging datasets around in designers). However, once you get past that one is able to do a lot of thing much more quickly then in asp(pagination or build a simple datatable with editing for example), I have however STILL never seen a large webforms project with an n-tier design that I thought was easy to follow, implement and use.
来自ASP并转到Web.Form和现在的MVC.Net我可以告诉你,WebForms有点烦人/令人沮丧的学习,90%的MS教程教你最坏的习惯IE(页面上的SQL连接,在设计师中拖动数据集)。然而,一旦你越过那个人能够更快地完成很多事情然后在asp(分页或构建一个简单的数据表,例如编辑),我仍然没有看到一个带有n层的大型webforms项目我认为易于遵循,实施和使用的设计。
MVC.NET is like a godsend. It forces patterns and practices down your throat, it has strict rules that are adhered to by most. It allows for easy code coverage and separation of concerns. After being frustrated with webforms for years it finally feels like I am not hacking things together when attempting to do something that I cant drag off the tool bar.
MVC.NET就像天赐之物。它强迫你的模式和做法,它有严格的规则,大多数人遵守。它允许简单的代码覆盖和关注点分离。在对webforms感到沮丧多年之后,最终感觉我在尝试做一些我无法拖出工具栏的事情时并没有将事情混在一起。
I personally would try webforms so you will know how much better MVC is when you start using it.
我个人会尝试使用webforms,这样你就会知道当你开始使用MVC时会有多好。
#4
2
There is more to ASP.NET-MVC than the apparent similarities between view code and ASP inline code. There is all the Model and Controller parts to consider which is very different from the way most ASP is written.
ASP.NET-MVC比视图代码和ASP内联代码之间的明显相似之处还要多。要考虑的所有模型和控制器部件与大多数ASP的编写方式都有很大不同。
That said I would say that MVC would be the best place to start.
那就是说我会说MVC将是最好的起点。
#5
1
IMO WebForms attempt to hide html too much for my liking and may cause your project to take longer than you would like due to converting a lot of html into the webforms controls.
IMO WebForms试图根据自己的喜好隐藏html,并且由于将大量html转换为webforms控件,可能会导致您的项目花费的时间超过您的预期。
On the other hand MVC allows you to reuse some of this logic while making your application much more maintainable and with the appropriate Architectural Pattern your application can be developed and refactored much quicker than any WebForms project.
另一方面,MVC允许您重用一些逻辑,同时使您的应用程序更易于维护,并且使用适当的架构模式,您的应用程序可以比任何WebForms项目更快地开发和重构。
I say MVC all the way!
我一直说MVC!
#6
1
Either way, it's always best to start from scratch and implemented only the logic.
无论哪种方式,始终最好从头开始并仅实现逻辑。
I started ASP a long time ago (more than 12 years ago) and only in 2006 I moved to ASP.NET 2.0, not even today I know all, but I do know pretty much what I do everyday at work.
我很久以前就开始使用ASP(超过12年前),直到2006年我才转向ASP.NET 2.0,即使在今天我也不知道所有,但我确实知道我每天在工作中做的事情。
In my opinion now, and looking back to my knowledge of ASP I would go to Web Forms instead of MVC, first, it's a language that it's in the "market" some some yeras now and very used across the world, while MVC is still in Beta, so, not suitable for production environment (says Microsoft - even if this site is written in MVC).
在我看来,现在回顾我对ASP的了解,我会去Web Forms而不是MVC,首先,它是一种语言,它现在在“市场”中有些已经在世界各地使用,而MVC仍在使用因此,不适合生产环境(微软说 - 即使这个网站是用MVC编写的)。
I do tend to make confusion with MVC diagram still, and there are more tricks than I want to learn if I need to do a fast change of one ASP project.
我确实倾向于混淆MVC图表,如果我需要快速更改一个ASP项目,还有比我想要学习更多的技巧。
#7
1
It depends. The ASP.NET MVC is no silver bullet and in many ways takes a few steps backwards in terms of developer productivity.
这取决于。 ASP.NET MVC不是银弹,并且在许多方面在开发人员生产力方面向后退了几步。
If you have a tight budget and need to get this done fast I believe ASP.Net is the way to go since it has the wealth of controls like grids, paging, validation etc that you can use right out of the box. Using these controls will no doubt save a lot of dev time. All of these controls that most consider pedestrian by now in ASP.NET all have to be created from scratch or taken from the Internet when you use the ASP.NET MVC project.
如果你的预算紧张并且需要快速完成,我相信ASP.Net是可行的方式,因为它具有丰富的控件,如网格,分页,验证等,您可以立即使用。使用这些控件无疑会节省大量的开发时间。目前在ASP.NET中大多数考虑行人的所有这些控件都必须从头开始创建,或者在使用ASP.NET MVC项目时从Internet获取。
On the other hand if you have the time and budget now and going forward, and you want to have a solution that is rock solid, and more easily lends itself to test driven development, the ASP.NET MVC is probably the best choice.
另一方面,如果您现在有时间和预算,并且希望有一个坚如磐石的解决方案,并且更容易适合测试驱动开发,那么ASP.NET MVC可能是最佳选择。
#8
1
Definately ASP.NET MVC is better in terms of style. (That said, you don't have to use Repeaters and other silly controls in a WebForms app, you can simply use inline code just like you would in MVC.)
绝对ASP.NET MVC在风格方面更好。 (也就是说,您不必在WebForms应用程序中使用Repeater和其他愚蠢的控件,您可以像在MVC中一样使用内联代码。)
MVC in general though would be an easier port, give you a better structure and be a more pleasant experience.
MVC一般来说会是一个更容易的端口,给你一个更好的结构,并获得更愉快的体验。
#9
1
Web Forms is more object-oriented, while MVC is like classic ASP on top of .NET code. Model design should be the same using Web Forms or MVC. The only difference is that Web Forms has an object-oriented abstraction to the UI and MVC uses functions and code snippets instead of classes to organize UI code.
Web Forms更面向对象,而MVC就像.NET代码之上的经典ASP。使用Web窗体或MVC,模型设计应该是相同的。唯一的区别是Web窗体具有面向对象的UI抽象,MVC使用函数和代码片段而不是类来组织UI代码。
#10
-1
ASP.NET MVC is better than Web Forms for automated unit testing of the UI. However, automated unit testing in general is bad practice and even worse for the UI. Manual testing is the best way to build a quality application and to make the best use of development time. Creating automated unit tests is a waste of time and you end up with junk code to maintain with the core code. Lots of developers like automated unit tests because they think they are proof their application works, which is false. They also are trying to avoid designing applications using UML so they are using test driven development to design using code which is responsible for poorly designed applications. With TDD, you are refactoring code you wrote poorly without thinking about the big picture using models in the first place.
ASP.NET MVC优于Web Forms,用于UI的自动单元测试。但是,自动单元测试通常是不好的做法,对UI来说更糟糕。手动测试是构建高质量应用程序和充分利用开发时间的最佳方式。创建自动化单元测试是浪费时间,最终使用垃圾代码来维护核心代码。许多开发人员喜欢自动化单元测试,因为他们认为它们证明了他们的应用程序有效,这是错误的。他们还试图避免使用UML设计应用程序,因此他们使用测试驱动开发来设计使用负责设计不佳的应用程序的代码。使用TDD,您可以重构您编写的代码,而不必考虑使用模型的大局。
So MVC is useless. Web Forms uses a better object oriented model whereas MVC is more like old style classic ASP and other older design patterns. This is 2010 and MVC is dead. Web Forms is like ORM for the UI.
所以MVC没用。 Web窗体使用更好的面向对象模型,而MVC更像旧式经典ASP和其他旧设计模式。这是2010年,MVC已经死了。 Web窗体就像用户界面的ORM。
#1
7
It depends a lot on how the classic asp app is structured.
这很大程度上取决于经典asp应用程序的结构。
The server tag mixed in with HTML is similar to asp.net mvc but MVC is not as messy (or not supposed to be). You might be able to move the classic asp presentation code to a MVC view easier than to a web form. Also classic asp apps were usually developed with the statelessness of the web in mind. There probably is not anything in your classic asp that matches postabacks or viewstate. Classic ASP also uses normal html elements as opposed to asp.net webform controls. In these respects it matches MVC a lot closer than webforms.
与HTML混合的服务器标签类似于asp.net mvc,但MVC并不是那么混乱(或者不应该是)。您可以将经典的asp演示代码移动到MVC视图比移动Web表单更容易。此外,经典的asp应用程序通常是在考虑到Web的无状态的情况下开发的。你的经典asp中可能没有任何东西与postabacks或viewstate相匹配。经典ASP还使用普通的html元素而不是asp.net webform控件。在这些方面,它比MVforms更接近MVC。
If you do not know asp.net webforms or asp.net mvc I would say MVC is the way to go.
如果你不知道asp.net webforms或asp.net mvc我会说MVC是要走的路。
If you know webforms very well and don't know much about MVC I would say webforms is the way to go.
如果你非常了解webforms并且对MVC知之甚少,我会说webforms是要走的路。
But, if your client for some reason does want a redevelopment of the site I would say go with MVC. It's always nice to have a client pay for part of your experience development as long as you can deliver.
但是,如果您的客户出于某种原因想要重新开发该网站,我会说与MVC一起去。只要您能够交付,让客户支付部分经验开发总是很好的。
On another note I'm always taken aback when I come across a client who wants me to do work on their classic asp site. In every single case the site is a mess. The worse part is that they are usually filled with huge security holes.
另一方面,当我遇到一位希望我在他们的经典asp网站上工作的客户时,我总是吃惊。在每一个案例中,网站都是一团糟。更糟糕的是,它们通常充满了巨大的安全漏洞。
#2
4
I think in a lot of cases it could be easier to convert to MVC than Webforms. Most classic ASP apps demonstrate very little separation of concerns so the biggest task is probably exactly that, seperating out the logic into data access, business logic, business entities and UI components. In doing that it could well be easier to convert the inline ASP code to a view, the business logic into controllers and the business entities into the model.
我认为在很多情况下,转换为MVC比Webforms更容易。大多数经典ASP应用程序几乎没有关注点分离,因此最大的任务可能就是将数据访问,业务逻辑,业务实体和UI组件分离出来。在这样做时,可以更容易地将内联ASP代码转换为视图,将业务逻辑转换为控制器,将业务实体转换为模型。
#3
4
I don't think one would be easier to convert then the other.
我不认为一个人比其他人更容易转换。
You can code ASP.NET almost the same as you code ASP if you wanted putting a few crucial elements in the codebehind that you could access in the aspx. No databinding, no gridview and no repeater. The view state is there to help you can is easy to figure out, it is not necessary to use it if you don't want and can be turned off in the web.config and turned on with a page attribute. Web forms also have an AspCompat mode which allows access to Request and Response objects or asp, which will allow for page by page conversion if desired.
如果你想在aspx中访问代码隐藏中的几个关键元素,你可以编写几乎与代码ASP相同的ASP.NET代码。没有数据绑定,没有gridview,也没有转发器。视图状态可以帮助您轻松搞清楚,如果您不想要它就没有必要使用它,可以在web.config中关闭并打开页面属性。 Web表单还具有AspCompat模式,允许访问Request和Response对象或asp,如果需要,可以进行逐页转换。
As for MVC.net, the method for displaying the HTML is quite similar. That in my opinion is where the similarities end. You would still need to separate out all you logic into the MVC model.
至于MVC.net,显示HTML的方法非常相似。在我看来,这就是相似之处的结束。您仍然需要将所有逻辑分离到MVC模型中。
Coming from ASP and going to Web.Form and now MVC.Net I can tell you that WebForms were a little annoying/frustrating to learn, with 90% of the MS tutorials teaching you the worst possible habits IE (SQL connections on the page, dragging datasets around in designers). However, once you get past that one is able to do a lot of thing much more quickly then in asp(pagination or build a simple datatable with editing for example), I have however STILL never seen a large webforms project with an n-tier design that I thought was easy to follow, implement and use.
来自ASP并转到Web.Form和现在的MVC.Net我可以告诉你,WebForms有点烦人/令人沮丧的学习,90%的MS教程教你最坏的习惯IE(页面上的SQL连接,在设计师中拖动数据集)。然而,一旦你越过那个人能够更快地完成很多事情然后在asp(分页或构建一个简单的数据表,例如编辑),我仍然没有看到一个带有n层的大型webforms项目我认为易于遵循,实施和使用的设计。
MVC.NET is like a godsend. It forces patterns and practices down your throat, it has strict rules that are adhered to by most. It allows for easy code coverage and separation of concerns. After being frustrated with webforms for years it finally feels like I am not hacking things together when attempting to do something that I cant drag off the tool bar.
MVC.NET就像天赐之物。它强迫你的模式和做法,它有严格的规则,大多数人遵守。它允许简单的代码覆盖和关注点分离。在对webforms感到沮丧多年之后,最终感觉我在尝试做一些我无法拖出工具栏的事情时并没有将事情混在一起。
I personally would try webforms so you will know how much better MVC is when you start using it.
我个人会尝试使用webforms,这样你就会知道当你开始使用MVC时会有多好。
#4
2
There is more to ASP.NET-MVC than the apparent similarities between view code and ASP inline code. There is all the Model and Controller parts to consider which is very different from the way most ASP is written.
ASP.NET-MVC比视图代码和ASP内联代码之间的明显相似之处还要多。要考虑的所有模型和控制器部件与大多数ASP的编写方式都有很大不同。
That said I would say that MVC would be the best place to start.
那就是说我会说MVC将是最好的起点。
#5
1
IMO WebForms attempt to hide html too much for my liking and may cause your project to take longer than you would like due to converting a lot of html into the webforms controls.
IMO WebForms试图根据自己的喜好隐藏html,并且由于将大量html转换为webforms控件,可能会导致您的项目花费的时间超过您的预期。
On the other hand MVC allows you to reuse some of this logic while making your application much more maintainable and with the appropriate Architectural Pattern your application can be developed and refactored much quicker than any WebForms project.
另一方面,MVC允许您重用一些逻辑,同时使您的应用程序更易于维护,并且使用适当的架构模式,您的应用程序可以比任何WebForms项目更快地开发和重构。
I say MVC all the way!
我一直说MVC!
#6
1
Either way, it's always best to start from scratch and implemented only the logic.
无论哪种方式,始终最好从头开始并仅实现逻辑。
I started ASP a long time ago (more than 12 years ago) and only in 2006 I moved to ASP.NET 2.0, not even today I know all, but I do know pretty much what I do everyday at work.
我很久以前就开始使用ASP(超过12年前),直到2006年我才转向ASP.NET 2.0,即使在今天我也不知道所有,但我确实知道我每天在工作中做的事情。
In my opinion now, and looking back to my knowledge of ASP I would go to Web Forms instead of MVC, first, it's a language that it's in the "market" some some yeras now and very used across the world, while MVC is still in Beta, so, not suitable for production environment (says Microsoft - even if this site is written in MVC).
在我看来,现在回顾我对ASP的了解,我会去Web Forms而不是MVC,首先,它是一种语言,它现在在“市场”中有些已经在世界各地使用,而MVC仍在使用因此,不适合生产环境(微软说 - 即使这个网站是用MVC编写的)。
I do tend to make confusion with MVC diagram still, and there are more tricks than I want to learn if I need to do a fast change of one ASP project.
我确实倾向于混淆MVC图表,如果我需要快速更改一个ASP项目,还有比我想要学习更多的技巧。
#7
1
It depends. The ASP.NET MVC is no silver bullet and in many ways takes a few steps backwards in terms of developer productivity.
这取决于。 ASP.NET MVC不是银弹,并且在许多方面在开发人员生产力方面向后退了几步。
If you have a tight budget and need to get this done fast I believe ASP.Net is the way to go since it has the wealth of controls like grids, paging, validation etc that you can use right out of the box. Using these controls will no doubt save a lot of dev time. All of these controls that most consider pedestrian by now in ASP.NET all have to be created from scratch or taken from the Internet when you use the ASP.NET MVC project.
如果你的预算紧张并且需要快速完成,我相信ASP.Net是可行的方式,因为它具有丰富的控件,如网格,分页,验证等,您可以立即使用。使用这些控件无疑会节省大量的开发时间。目前在ASP.NET中大多数考虑行人的所有这些控件都必须从头开始创建,或者在使用ASP.NET MVC项目时从Internet获取。
On the other hand if you have the time and budget now and going forward, and you want to have a solution that is rock solid, and more easily lends itself to test driven development, the ASP.NET MVC is probably the best choice.
另一方面,如果您现在有时间和预算,并且希望有一个坚如磐石的解决方案,并且更容易适合测试驱动开发,那么ASP.NET MVC可能是最佳选择。
#8
1
Definately ASP.NET MVC is better in terms of style. (That said, you don't have to use Repeaters and other silly controls in a WebForms app, you can simply use inline code just like you would in MVC.)
绝对ASP.NET MVC在风格方面更好。 (也就是说,您不必在WebForms应用程序中使用Repeater和其他愚蠢的控件,您可以像在MVC中一样使用内联代码。)
MVC in general though would be an easier port, give you a better structure and be a more pleasant experience.
MVC一般来说会是一个更容易的端口,给你一个更好的结构,并获得更愉快的体验。
#9
1
Web Forms is more object-oriented, while MVC is like classic ASP on top of .NET code. Model design should be the same using Web Forms or MVC. The only difference is that Web Forms has an object-oriented abstraction to the UI and MVC uses functions and code snippets instead of classes to organize UI code.
Web Forms更面向对象,而MVC就像.NET代码之上的经典ASP。使用Web窗体或MVC,模型设计应该是相同的。唯一的区别是Web窗体具有面向对象的UI抽象,MVC使用函数和代码片段而不是类来组织UI代码。
#10
-1
ASP.NET MVC is better than Web Forms for automated unit testing of the UI. However, automated unit testing in general is bad practice and even worse for the UI. Manual testing is the best way to build a quality application and to make the best use of development time. Creating automated unit tests is a waste of time and you end up with junk code to maintain with the core code. Lots of developers like automated unit tests because they think they are proof their application works, which is false. They also are trying to avoid designing applications using UML so they are using test driven development to design using code which is responsible for poorly designed applications. With TDD, you are refactoring code you wrote poorly without thinking about the big picture using models in the first place.
ASP.NET MVC优于Web Forms,用于UI的自动单元测试。但是,自动单元测试通常是不好的做法,对UI来说更糟糕。手动测试是构建高质量应用程序和充分利用开发时间的最佳方式。创建自动化单元测试是浪费时间,最终使用垃圾代码来维护核心代码。许多开发人员喜欢自动化单元测试,因为他们认为它们证明了他们的应用程序有效,这是错误的。他们还试图避免使用UML设计应用程序,因此他们使用测试驱动开发来设计使用负责设计不佳的应用程序的代码。使用TDD,您可以重构您编写的代码,而不必考虑使用模型的大局。
So MVC is useless. Web Forms uses a better object oriented model whereas MVC is more like old style classic ASP and other older design patterns. This is 2010 and MVC is dead. Web Forms is like ORM for the UI.
所以MVC没用。 Web窗体使用更好的面向对象模型,而MVC更像旧式经典ASP和其他旧设计模式。这是2010年,MVC已经死了。 Web窗体就像用户界面的ORM。