Possible Duplicate:
MVC versus WebForms
ASP.NET MVC Performance可能重复:MVC与WebForms ASP.NET MVC性能
I'll be starting a new web project in the coming weeks. It's a public facing web site for a somewhat famous person. I have 2 choices: use good-old ASP.NET 4 or new ASP.NET MVC 3 with Razor.
我将在未来几周内开始一个新的网络项目。对于一个有名的人来说,这是一个面向公众的网站。我有两个选择:使用古老的ASP.NET 4或使用Razor的新ASP.NET MVC 3。
I do not plan to do any kind of unit testing. It's rather simple website mainly consisting of javascript, html and css.
我不打算做任何单元测试。这是一个相当简单的网站,主要由javascript,html和css组成。
I'll need to build an admin panel to create/delete/edit pages; add/remove pictures to portfolio gallery. And that's probably all I need from an admin panel. Nothing complicated.
我需要建立一个管理面板来创建/删除/编辑页面;添加/删除图片到投资组合库。这可能就是我需要的一个管理面板。没什么复杂的。
Disclaimer: I do not have much experience with either Webforms or MVC, other than what I have learned from Pluralsight Training and ASP.NET Official Tutorials. I do have intermediate knowledge of css and html; no experience with javascript. But given how javascript is so similar to other OOP languages I am not too worried if I have to get my hands dirty with JS.
免责声明:除了我从Pluralsight Training和ASP.NET官方教程中学到的知识之外,我对Webforms或MVC没有多少经验。我对css和html有中级知识;没有javascript经验。但鉴于javascript如何与其他OOP语言如此相似,我不会太担心,如果我必须弄清楚JS。
- In terms of development speed, which would be faster: WebForms or MVC?
- How about out-of-box performance between the two?
- In a long term which would be easier to maintain?
在开发速度方面,哪个更快:WebForms还是MVC?
两者之间的开箱即用表现怎么样?
从长远来看,哪个更容易维护?
If you advise against starting a web project from scratch, perhaps you could recommend a light ASP.NET CMS instead?
如果您建议不要从头开始创建Web项目,也许您可以推荐一个简单的ASP.NET CMS?
6 个解决方案
#1
14
In terms of development speed, which would be faster: webforms or mvc?
在开发速度方面,哪个会更快:webforms还是mvc?
This depends on many factors, but suppose that you use eqal technologies both with webforms and mvc then mvc should be faster. Webforms has some overhead because of the mismatch between how things really work (eg. that http is stateless) and what is assumed while writing the code (you're programming as if the application was stateful)
这取决于很多因素,但假设您使用eqal技术和webforms以及mvc,那么mvc应该更快。 Webforms有一些开销,因为事情真正起作用之间的不匹配(例如,http是无状态的)和编写代码时的假设(你编程好像应用程序是有状态的)
In a long term which would be easier to maintain?
从长远来看,哪个更容易维护?
IMO MVC is easier to maintain, because it's easier to change bare html/js code, the model(MVC) is well defined which makes it less painful for a new person to get to figure out how everything works.
IMO MVC更易于维护,因为它更容易更改裸html / js代码,模型(MVC)定义明确,这使得新人更难以弄清楚一切是如何工作的。
I'll need to build an admin panel to create/delete/edit pages; add/remove pictures to portfolio gallery.
我需要建立一个管理面板来创建/删除/编辑页面;添加/删除图片到投资组合库。
This is the kind of thing that MVC is good with - define entities and quickly create List/Details/Create/Edit/Delete actions and views.
这是MVC很好的东西 - 定义实体并快速创建List / Details / Create / Edit / Delete动作和视图。
PS> I'm not saying that plain old ASP.NET Webforms is bad, it's just that it sometimes becomes too complicated and you need to pay the price for it. I think that open source e-commerce solution - NopCommerce is a good example. It's well designed, well written, but it's really slow because of the overhead that is needed for web forms.
PS>我不是说普通的旧ASP.NET Webforms很糟糕,只是它有时变得太复杂而你需要付出代价。我认为开源电子商务解决方案--NopCommerce就是一个很好的例子。它设计得很好,编写得很好,但由于Web表单需要的开销很慢,所以它确实很慢。
#2
5
In terms of development speed, which would be faster: webforms or mvc?
在开发速度方面,哪个会更快:webforms还是mvc?
WebForms can be a little faster to develop since it's a lot of R.A.D. development. Long term however, you will regret not separating your concerns. Keeping a separation of concerns may take longer but is a lot easier to maintain after the fact.
WebForms的开发速度要快一些,因为很多R.A.D.发展。但是,长期而言,您会后悔没有将您的疑虑分开。保持关注点分离可能需要更长时间,但事后更容易维护。
How about out-of-box performance between the two?
两者之间的开箱即用表现怎么样?
MVC will perform better since there is no "extras" being passed between the controller and the View. you only pass what's necessary (IE: no ViewState)
MVC将表现得更好,因为控制器和View之间没有“额外”。你只传递了必要的东西(IE:没有ViewState)
In a long term which would be easier to maintain?
从长远来看,哪个更容易维护?
Back to what I mentioned above. Keeping a separation of concerns may take longer but is a lot easier to maintain after the fact.
回到我上面提到的。保持关注点分离可能需要更长时间,但事后更容易维护。
#3
2
There are pros and cons for both web forms and MVC. But you don't have to choose. You can use the nuget package for adding MVC to a web forms application. You just have to start with web forms and then it will incorporate the MVC. That way you can have the best of both worlds depending on what your needs are.
Web表单和MVC都有利弊。但你不必选择。您可以使用nuget包将MVC添加到Web表单应用程序。您只需从Web表单开始,然后它将包含MVC。这样,根据您的需求,您可以拥有两全其美。
Here is the link to that nuget package from Scott Hanselman.
以下是Scott Hanselman提供的nuget包的链接。
If you are just looking to do a CMS then you should definitely use Orchard
如果你只是想做一个CMS,那么你一定要使用Orchard
#4
2
In terms of development speed, which would be faster: webforms or mvc?
在开发速度方面,哪个会更快:webforms还是mvc?
Some would argue Web Forms because of the "off the shelf" server controls that can do basically anything you want. Whilst this may have been true in the intial version of MVC, now that we are at v3 and the community is getting heavily involved - you'll be able to find a MVC-port (e.g custom HTML helper) to do those things for you.
有些人认为Web Forms是因为“现成的”服务器控件基本上可以做任何你想做的事情。虽然在初始版本的MVC中可能已经存在这种情况,但现在我们处于v3并且社区正在积极参与 - 您将能够找到一个MVC端口(例如自定义HTML助手)来为您做这些事情。
Not to mention the vast scaffolding improvements in the MVC tooling will make your "CRUD" life a hell of a lot faster.
更不用说MVC工具中巨大的脚手架改进将使你的“CRUD”生活变得更快。
So it's hard to categorize "development", but in terms of getting a full page running based on a backend database, i'd say MVC is faster.
因此很难对“开发”进行分类,但就基于后端数据库运行整页运行而言,我认为MVC更快。
How about out-of-box performance between the two?
两者之间的开箱即用表现怎么样?
That's tough to answer. Anything with performance is. I've read somewhere that the Razor view engine is marginally faster than the ASPX view engine, which is what Web Forms is based on. Add onto that things like ViewState, and i'd have to say (without any backing "facts") that MVC would be faster. But don't look to the technology to have well performing applications, look to yourself to write optimal code using the technologies at hand.
这很难回答。任何有表现的东西都是。我在某处读过Razor视图引擎比ASPX视图引擎略快,这是Web Forms的基础。加上像ViewState这样的东西,我不得不说(没有任何支持“事实”)MVC会更快。但是,不要期望该技术具有良好的性能应用程序,期待自己使用手头的技术编写最佳代码。
In a long term which would be easier to maintain?
从长远来看,哪个更容易维护?
Definetely MVC - no question on this one. SoC (seperation of concerns) is a huge pushing point in MVC, not only with the M-V-C segregration, but also the "convention over configuration" approach that is at the heart of MVC. EditorTemplates and DisplayTemplates are a perfect example of this - they work off convention (the model type being passed to it). So you can create multiple templates and flick over different model types without any backend code changes.
定义MVC - 对此问题毫无疑问。 SoC(关注点的分离)是MVC的一个巨大推动点,不仅与M-V-C隔离有关,而且与MVC核心的“约定优于配置”方法有关。 EditorTemplates和DisplayTemplates就是一个很好的例子 - 它们可以用于约定(传递给它的模型类型)。因此,您可以创建多个模板并轻松浏览不同的模型类型,而无需更改任何后端代码。
That being said - nothing stopping you from having a well seperated and layed out Web Forms application - but there's only so far you can go without hitting a roadblock in the technology itself - such as the "code behind model" which cannot be avoided.
话虽这么说 - 没有什么可以阻止你分离出来并放置Web窗体应用程序 - 但是只有到目前为止你才能在技术本身没有遇到障碍 - 例如无法避免的“模型背后的代码”。
Overall - MVC FTW.
总体而言 - MVC FTW。
#5
1
Orchard is the MVC cms of note.
Orchard是值得关注的MVC cms。
If you are going to pick a pre-built CMS, pick it based on the merits of the CMS. MVC vs Web Forms probably doesn't matter too much here if you know what you are looking to build.
如果您要选择预先构建的CMS,请根据CMS的优点选择它。如果你知道你想要构建什么,MVC vs Web Forms在这里可能并不重要。
If you are intent in building this yourself and you are comfortable with Html, Css and Javascript then you probably want to do MVC3. Presuming you have some underlying web skills, MVC3 really has erased most of the potential productivity advantages of web forms.
如果你打算自己构建这个并且你对Html,Css和Javascript感到满意,那么你可能想要做MVC3。假设你有一些潜在的网络技能,MVC3确实抹去了网络表单的大部分潜在的生产力优势。
#6
#1
14
In terms of development speed, which would be faster: webforms or mvc?
在开发速度方面,哪个会更快:webforms还是mvc?
This depends on many factors, but suppose that you use eqal technologies both with webforms and mvc then mvc should be faster. Webforms has some overhead because of the mismatch between how things really work (eg. that http is stateless) and what is assumed while writing the code (you're programming as if the application was stateful)
这取决于很多因素,但假设您使用eqal技术和webforms以及mvc,那么mvc应该更快。 Webforms有一些开销,因为事情真正起作用之间的不匹配(例如,http是无状态的)和编写代码时的假设(你编程好像应用程序是有状态的)
In a long term which would be easier to maintain?
从长远来看,哪个更容易维护?
IMO MVC is easier to maintain, because it's easier to change bare html/js code, the model(MVC) is well defined which makes it less painful for a new person to get to figure out how everything works.
IMO MVC更易于维护,因为它更容易更改裸html / js代码,模型(MVC)定义明确,这使得新人更难以弄清楚一切是如何工作的。
I'll need to build an admin panel to create/delete/edit pages; add/remove pictures to portfolio gallery.
我需要建立一个管理面板来创建/删除/编辑页面;添加/删除图片到投资组合库。
This is the kind of thing that MVC is good with - define entities and quickly create List/Details/Create/Edit/Delete actions and views.
这是MVC很好的东西 - 定义实体并快速创建List / Details / Create / Edit / Delete动作和视图。
PS> I'm not saying that plain old ASP.NET Webforms is bad, it's just that it sometimes becomes too complicated and you need to pay the price for it. I think that open source e-commerce solution - NopCommerce is a good example. It's well designed, well written, but it's really slow because of the overhead that is needed for web forms.
PS>我不是说普通的旧ASP.NET Webforms很糟糕,只是它有时变得太复杂而你需要付出代价。我认为开源电子商务解决方案--NopCommerce就是一个很好的例子。它设计得很好,编写得很好,但由于Web表单需要的开销很慢,所以它确实很慢。
#2
5
In terms of development speed, which would be faster: webforms or mvc?
在开发速度方面,哪个会更快:webforms还是mvc?
WebForms can be a little faster to develop since it's a lot of R.A.D. development. Long term however, you will regret not separating your concerns. Keeping a separation of concerns may take longer but is a lot easier to maintain after the fact.
WebForms的开发速度要快一些,因为很多R.A.D.发展。但是,长期而言,您会后悔没有将您的疑虑分开。保持关注点分离可能需要更长时间,但事后更容易维护。
How about out-of-box performance between the two?
两者之间的开箱即用表现怎么样?
MVC will perform better since there is no "extras" being passed between the controller and the View. you only pass what's necessary (IE: no ViewState)
MVC将表现得更好,因为控制器和View之间没有“额外”。你只传递了必要的东西(IE:没有ViewState)
In a long term which would be easier to maintain?
从长远来看,哪个更容易维护?
Back to what I mentioned above. Keeping a separation of concerns may take longer but is a lot easier to maintain after the fact.
回到我上面提到的。保持关注点分离可能需要更长时间,但事后更容易维护。
#3
2
There are pros and cons for both web forms and MVC. But you don't have to choose. You can use the nuget package for adding MVC to a web forms application. You just have to start with web forms and then it will incorporate the MVC. That way you can have the best of both worlds depending on what your needs are.
Web表单和MVC都有利弊。但你不必选择。您可以使用nuget包将MVC添加到Web表单应用程序。您只需从Web表单开始,然后它将包含MVC。这样,根据您的需求,您可以拥有两全其美。
Here is the link to that nuget package from Scott Hanselman.
以下是Scott Hanselman提供的nuget包的链接。
If you are just looking to do a CMS then you should definitely use Orchard
如果你只是想做一个CMS,那么你一定要使用Orchard
#4
2
In terms of development speed, which would be faster: webforms or mvc?
在开发速度方面,哪个会更快:webforms还是mvc?
Some would argue Web Forms because of the "off the shelf" server controls that can do basically anything you want. Whilst this may have been true in the intial version of MVC, now that we are at v3 and the community is getting heavily involved - you'll be able to find a MVC-port (e.g custom HTML helper) to do those things for you.
有些人认为Web Forms是因为“现成的”服务器控件基本上可以做任何你想做的事情。虽然在初始版本的MVC中可能已经存在这种情况,但现在我们处于v3并且社区正在积极参与 - 您将能够找到一个MVC端口(例如自定义HTML助手)来为您做这些事情。
Not to mention the vast scaffolding improvements in the MVC tooling will make your "CRUD" life a hell of a lot faster.
更不用说MVC工具中巨大的脚手架改进将使你的“CRUD”生活变得更快。
So it's hard to categorize "development", but in terms of getting a full page running based on a backend database, i'd say MVC is faster.
因此很难对“开发”进行分类,但就基于后端数据库运行整页运行而言,我认为MVC更快。
How about out-of-box performance between the two?
两者之间的开箱即用表现怎么样?
That's tough to answer. Anything with performance is. I've read somewhere that the Razor view engine is marginally faster than the ASPX view engine, which is what Web Forms is based on. Add onto that things like ViewState, and i'd have to say (without any backing "facts") that MVC would be faster. But don't look to the technology to have well performing applications, look to yourself to write optimal code using the technologies at hand.
这很难回答。任何有表现的东西都是。我在某处读过Razor视图引擎比ASPX视图引擎略快,这是Web Forms的基础。加上像ViewState这样的东西,我不得不说(没有任何支持“事实”)MVC会更快。但是,不要期望该技术具有良好的性能应用程序,期待自己使用手头的技术编写最佳代码。
In a long term which would be easier to maintain?
从长远来看,哪个更容易维护?
Definetely MVC - no question on this one. SoC (seperation of concerns) is a huge pushing point in MVC, not only with the M-V-C segregration, but also the "convention over configuration" approach that is at the heart of MVC. EditorTemplates and DisplayTemplates are a perfect example of this - they work off convention (the model type being passed to it). So you can create multiple templates and flick over different model types without any backend code changes.
定义MVC - 对此问题毫无疑问。 SoC(关注点的分离)是MVC的一个巨大推动点,不仅与M-V-C隔离有关,而且与MVC核心的“约定优于配置”方法有关。 EditorTemplates和DisplayTemplates就是一个很好的例子 - 它们可以用于约定(传递给它的模型类型)。因此,您可以创建多个模板并轻松浏览不同的模型类型,而无需更改任何后端代码。
That being said - nothing stopping you from having a well seperated and layed out Web Forms application - but there's only so far you can go without hitting a roadblock in the technology itself - such as the "code behind model" which cannot be avoided.
话虽这么说 - 没有什么可以阻止你分离出来并放置Web窗体应用程序 - 但是只有到目前为止你才能在技术本身没有遇到障碍 - 例如无法避免的“模型背后的代码”。
Overall - MVC FTW.
总体而言 - MVC FTW。
#5
1
Orchard is the MVC cms of note.
Orchard是值得关注的MVC cms。
If you are going to pick a pre-built CMS, pick it based on the merits of the CMS. MVC vs Web Forms probably doesn't matter too much here if you know what you are looking to build.
如果您要选择预先构建的CMS,请根据CMS的优点选择它。如果你知道你想要构建什么,MVC vs Web Forms在这里可能并不重要。
If you are intent in building this yourself and you are comfortable with Html, Css and Javascript then you probably want to do MVC3. Presuming you have some underlying web skills, MVC3 really has erased most of the potential productivity advantages of web forms.
如果你打算自己构建这个并且你对Html,Css和Javascript感到满意,那么你可能想要做MVC3。假设你有一些潜在的网络技能,MVC3确实抹去了网络表单的大部分潜在的生产力优势。