C# .NET 不同 MVC 框架的优缺点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1116882/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 08:35:56  来源:igfitidea点击:

Pros and cons of different MVC frameworks for .NET

c#.netmodel-view-controller

提问by mfloryan

With all the hype around MVC (and rightly so) I've decided to give it a go myself and write my first .NET MVC web application. With a few options to choose from I was wondering which framework MVC do people recommend.

随着围绕 MVC 的所有炒作(这是正确的),我决定自己尝试一下并编写我的第一个 .NET MVC Web 应用程序。有几个选项可供选择,我想知道人们推荐哪种框架 MVC

It seems like the first two are really the top contenders. Also some DI container is a natural complement to MVC - MonoRail would come with onealready while ASP.NET MVC could perhaps work with something like Unity.

前两个似乎是真正的顶级竞争者。此外,一些 DI 容器是 MVC 的自然补充——MonoRail 已经附带了一个,而 ASP.NET MVC 或许可以与Unity 之类的东西一起使用。

采纳答案by teh_noob

I think the best option would be Microsoft ASP.NET MVC for the following reasons:

我认为最好的选择是 Microsoft ASP.NET MVC,原因如下:

  • It's official.
  • It will have integration with visual studio 2010.
  • It was developed by people who work for Microsoft.
  • It's free.
  • It has a large fan base of developers that swear by it.
  • It has lots of documentation and information surrounding it.
  • The power of .NET at your fingertips.
  • Not limited to developing in one language.
  • 这是官方的。
  • 它将与 Visual Studio 2010 集成。
  • 它是由为 Microsoft 工作的人开发的。
  • 免费。
  • 它拥有大量的开发人员粉丝群,他们发誓。
  • 它有很多围绕它的文档和信息。
  • .NET 的强大功能触手可及。
  • 不限于用一种语言进行开发。

回答by Hannoun Yassir

Microsoft ASP.NET MVC

微软 ASP.NET MVC

pro : you can take advantage of .net and your experience with asp.net

亲:您可以利用 .net 和您在 asp.net 方面的经验

回答by Marc Gravell

ASP.NET MVC comes with all the common DI frameworks available on code-project, and it is pretty easy to do it yourself, too - I rewrote the StructureMap one to support some specific scenarios (picking the SM configuration out of the route data).

ASP.NET MVC 附带了代码项目上可用的所有常见 DI 框架,而且自己也很容易实现 - 我重写了 StructureMap 以支持一些特定场景(从路由数据中选择 SM 配置) .

So that deals with the main differentiator you mentioned in the question ;-p

因此,这涉及您在问题中提到的主要区别;-p

I'd use ASP.NET MVC, personally... but it could come close either way. I simply expect ASP.NET MVC to be more mainstream, what with the "official" card leading to more books/community/etc.

我个人会使用 ASP.NET MVC ......但它可以接近任何一种方式。我只是希望 ASP.NET MVC 更加主流,而“官方”卡片会带来更多书籍/社区/等。

Just look at the tags count here on SO; asp.net-mvc (and similar) 4k+; monorail... hard to find...

只需查看此处的标签计数即可;asp.net-mvc(和类似的)4k+;单轨列车……很难找到……

回答by Kumar

It essentially comes down to what you're looking to get out of it

它本质上归结为你想要从中得到什么

That said it's hard to beat asp.net mvc as it's * actively maintained * consistent/easy to use naming conventions ( if that doesn't make sense, feel free to skip this :) * well documented with source code/tutorials/handon labs et al * scales well out the box with other options available

也就是说很难击败 asp.net mvc,因为它 * 积极维护 * 一致/易于使用的命名约定(如果这没有意义,请随意跳过这个 :) * 源代码/教程/handon labs 有很好的文档记录等人 * 可以很好地扩展开箱即用的其他选项

I had not heard/seen the last 2 choices and while i did browse those links, i'm not going to invest my time learning/reading about them considering asp.net mvc is out there - my 0.02

我没有听到/看到最后 2 个选项,虽然我确实浏览了这些链接,但考虑到 asp.net mvc 已经存在,我不会花时间学习/阅读它们 - 我的 0.02

回答by KRopa

One that hasn't been mentioned here is my favorite since 2014, NancyFx, inspired by Sinatrafrom the Ruby world.

这里没有提到的是自 2014 年以来我最喜欢的 NancyFx,其灵感来自 Ruby 世界的Sinatra

Almost no overhead, unlike the heavyweight official ASP.NET MVC.

几乎没有开销,不像重量级的官方 ASP.NET MVC。

It works with OWIN and Razor templates (& others too) and is easy to extend.

它适用于 OWIN 和 Razor 模板(以及其他模板)并且易于扩展。

Best feature is you can write routes to both services and views in the same MVC controller class, which Nancy calls a "Module"

最好的特性是你可以在同一个 MVC 控制器类中编写服务和视图的路由,南希称之为“模块”