对于新项目如何决定 WebForms 与 ASP.NET MVC 3?

发布于 2024-11-05 19:30:41 字数 891 浏览 3 评论 0原文

可能的重复:
MVC 与 WebForms
ASP.NET MVC 性能

我将在未来几周内开始一个新的 Web 项目。这是一个面向公众的网站,为一位颇有名气的人服务。我有 2 个选择:使用旧的 ASP.NET 4 或带有 Razor 的新 ASP.NET MVC 3。

计划进行任何类型的单元测试。这是一个相当简单的网站,主要由 javascript、html 和 css 组成。

我需要构建一个管理面板来创建/删除/编辑页面;添加/删除图片到投资组合库。这可能就是我需要的管理面板的全部内容。没什么复杂的。

免责声明除了从 Pluralsight 培训和 ASP.NET 官方教程中学到的知识外,我对 Webform 或 MVC 没有太多经验。我确实有 css 和 html 的中级知识;没有 JavaScript 经验。但鉴于 javascript 与其他 OOP 语言如此相似,我不太担心是否必须亲自接触 JS。

  • 就开发速度而言,这会更快:WebForms还是MVC
  • 两者之间的开箱即用性能如何?
  • 从长远来看,哪个更容易维护?

如果您建议不要从头开始一个 Web 项目,也许您可​​以推荐一个轻型 ASP.NET CMS?

Possible Duplicate:
MVC versus WebForms
ASP.NET MVC Performance

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.

I do not plan to do any kind of unit testing. It's rather simple website mainly consisting of javascript, html and 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.

  • 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?

If you advise against starting a web project from scratch, perhaps you could recommend a light ASP.NET CMS instead?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

云柯 2024-11-12 19:30:41

就开发速度而言,webform 和 mvc 哪个更快?

这取决于许多因素,但假设您将 eqal 技术与 Webforms 和 MVC 一起使用,那么 MVC 应该更快。 Webforms 有一些开销,因为实际工作方式(例如,http 是无状态的)与编写代码时的假设(您在编程时就好像应用程序是有状态的一样)之间不匹配

从长远来看,哪个更容易维护?

IMO MVC 更容易维护,因为更容易更改裸 html/js 代码,模型(MVC)定义良好,这使得新人更容易弄清楚一切是如何工作的。

我需要构建一个管理面板来创建/删除/编辑页面;添加/删除图片到投资组合库。

这就是 MVC 擅长的事情 - 定义实体并快速创建列表/详细信息/创建/编辑/删除操作和视图。

PS>我并不是说普通的旧 ASP.NET Webform 不好,只是它有时变得太复杂,您需要为此付出代价。我认为开源电子商务解决方案 - NopCommerce 就是一个很好的例子。它设计得很好,写得也很好,但由于 Web 表单所需的开销,它确实很慢。

In terms of development speed, which would be faster: webforms or 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)

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.

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.

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.

你的他你的她 2024-11-12 19:30:41

就开发速度而言,webformsmvc 哪个更快?

WebForms 的开发速度可能会更快一点,因为它需要大量的 RAD 开发。然而从长远来看,你会后悔没有分开你的关注点。保持关注点分离可能需要更长的时间,但事后维护起来要容易得多。

两者之间的开箱即用性能如何?

MVC 将执行得更好,因为控制器和视图之间没有传递“额外内容”。你只传递必要的内容(即:没有 ViewState)

从长远来看,哪个更容易维护?

回到我上面提到的。保持关注点分离可能需要更长的时间,但事后维护起来要容易得多。

In terms of development speed, which would be faster: webforms or 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.

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)

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.

蓝颜夕 2024-11-12 19:30:41

Web 表单和 MVC 各有利弊。但你不必选择。您可以使用 nuget 包将 MVC 添加到 Web 表单应用程序。您只需从 Web 表单开始,然后它就会合并 MVC。这样,您就可以根据您的需求,两全其美。

这里是 Scott Hanselman 提供的 nuget 包的链接

如果你只是想做一个 CMS 那么你绝对应该使用 Orchard

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.

Here is the link to that nuget package from Scott Hanselman.

If you are just looking to do a CMS then you should definitely use Orchard

剑心龙吟 2024-11-12 19:30:41

就开发速度而言,webform 和 mvc 哪个更快?

有些人会争论 Web 窗体,因为“现成的”服务器控件基本上可以做您想做的任何事情。虽然这在 MVC 的初始版本中可能是正确的,但现在我们已经到了 v3 并且社区正在积极参与 - 您将能够找到一个 MVC 端口(例如自定义 HTML 帮助器)来为您做这些事情。

更不用说 MVC 工具中的巨大脚手架改进将使您的“CRUD”生活快得多。

所以很难对“开发”进行分类,但就基于后端数据库运行完整页面而言,我认为 MVC 更快。

两者之间的开箱即用性能如何?

这很难回答。任何有性能的东西都是。我在某处读到,Razor 视图引擎比 ASPX 视图引擎稍快,而 ASPX 视图引擎正是 Web 窗体的基础。再加上像 ViewState 这样的东西,我不得不说(没有任何支持“事实”)MVC 会更快。但是,不要指望技术能够拥有性能良好的应用程序,而应该依靠自己使用现有的技术编写最佳代码。

从长远来看,哪个更容易维护?

绝对是 MVC——这一点毫无疑问。 SoC(关注点分离)是 MVC 的一个巨大推动点,不仅是 MVC 分离,而且是 MVC 核心的“约定优于配置”方法。 EditorTemplates 和 DisplayTemplates 就是一个完美的例子 - 它们打破惯例(传递给它的模型类型)。因此,您可以创建多个模板并切换不同的模型类型,而无需更改任何后端代码。

话虽这么说,没有什么可以阻止您拥有一个良好分离和布局的 Web 窗体应用程序,但您只能走到这一步,而不会遇到技术本身的障碍,例如无法避免的“模型背后的代码”。

总体而言 - MVC FTW

In terms of development speed, which would be faster: webforms or 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.

Not to mention the vast scaffolding improvements in the MVC tooling will make your "CRUD" life a hell of a lot faster.

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.

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.

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.

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.

Overall - MVC FTW.

夏日落 2024-11-12 19:30:41

Orchard 是值得注意的 MVC cms。

如果您要选择预构建的 CMS,请根据 CMS 的优点进行选择。如果您知道自己想要构建什么,那么 MVC 与 Web 表单在这里可能并不重要。

如果您打算自己构建它并且熟悉 Html、Css 和 Javascript,那么您可能想要使用 MVC3。假设您具备一些基础 Web 技能,MVC3 确实消除了 Web 表单的大部分潜在生产力优势。

Orchard is the MVC cms of note.

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.

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.

猫卆 2024-11-12 19:30:41

Umbraco 是一个免费的 CMS,非常棒并且基于 .NET。

http://umbraco.com/

Umbraco is a free CMS, awesome and .NET based.

http://umbraco.com/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文