简体   繁体   English

asp.net core 2.0 dotvvm vs razor pages - 对于交互式 Web 应用程序,哪一个更强大?

[英]asp.net core 2.0 dotvvm vs razor pages - which one is more powerful for an interactive web app?

With the latest release of ASP.NET CORE version 2.0 we now have Razor Pages which I really like because it shows a MVVM way of developing which I am already familiar because I've used it in UWP .随着ASP.NET CORE 2.0 版的最新版本,我们现在有了Razor Pages ,我非常喜欢它,因为它展示了一种MVVM的开发方式,我已经熟悉了,因为我已经在UWP 中使用过它。

I was searching to develop web apps without js because I am a .net developer and I came across this framework known as DOTVVM , it is great because it gives some features of js frameworks like Angular, React etc. and it also integrates very well with ASP.NET CORE 2.0我一直在寻找不使用js开发 Web 应用程序,因为我是.net 开发人员,我遇到了这个称为DOTVVM 的框架,它很棒,因为它提供了一些 js 框架的功能,如 Angular、React 等。它也与ASP.NET 核心 2.0

I want to discuss this between following 3 scenarios :我想在以下 3 个场景之间讨论这个:

  • I should use DOTVVM and not use JS at all.我应该使用DOTVVM而根本不使用 JS。

  • I should use Razor pages instead with asp.net core 2.0, because razor pages provide all functionality which dotvvm provides and it will have more community in future.我应该使用Razor 页面而不是 asp.net core 2.0,因为 razor 页面提供了 dotvvm 提供的所有功能,并且将来会有更多社区。

  • I should learn a JS framework like Angular or React because neither razor pages, nor dotvvm is powerful enough to replace them.我应该学习像 Angular 或 React 这样的JS 框架,因为无论是 razor pages 还是 dotvvm 都不足以取代它们。

The discussion can be from point of view of all developers, so I can get opinion of JS developers as well as those who have worked with dotvvm or Razor pages .讨论可以从所有开发人员的角度进行,所以我可以得到JS开发人员以及那些使用过dotvvmRazor pages 的人的意见 The aim is to create completely interactive and responsive web app with good performance.目的是创建具有良好性能的完全交互式和响应式网络应用程序。

**Important : ** the web app created can be a progressive web app from the start or maybe turned into a pwa after creating it, depends on the technology I choose at the end. **重要:** 创建的网络应用程序可以从一开始就是渐进式网络应用程序,也可以在创建后变成pwa ,这取决于我最后选择的技术。

I know for a progressive web app I will need to write a little JS, but that is alright considering that is very simple and little to write.我知道对于渐进式 Web 应用程序,我需要编写一些 JS,但考虑到它非常简单且很少编写,这没关系。

The reason of this question is so that we can discuss these options from multiple perspectives and deduce a better option at the end for my app.这个问题的原因是为了让我们可以从多个角度讨论这些选项,并在最后为我的应用程序推断出更好的选项。

It really depends on the type of the application you are trying to create.这实际上取决于您尝试创建的应用程序的类型。 The fact is that you can build any application in any web technology .事实上,您可以使用任何 Web 技术构建任何应用程序 The difference is only in how difficult it would be .不同之处仅在于难度有多大


Razor Pages are very easy to use and they are part of ASP.NET Core platform. Razor Pages非常易于使用,它们是 ASP.NET Core 平台的一部分。 They are using the MVVM pattern, but they are not helping with client interactivity.他们正在使用 MVVM 模式,但对客户端交互没有帮助。 If you need to hide some form field based on some condition, you would need to do it in JavaScript.如果您需要根据某些条件隐藏某些表单字段,则需要在 JavaScript 中进行。

I would use them for a simple company website, very simple admin sites with few pages and trivial forms, or for a public facing part of some eCommerce site.我会将它们用于一个简单的公司网站,非常简单的管理网站,页面很少,表格简单,或者用于某些电子商务网站的面向公众的部分。 I would probably use also jQuery or other libraries to do the interactivity, animations and things like that.我可能还会使用 jQuery 或其他库来进行交互、动画和类似的操作。


DotVVM is an MVVM framework which helps especially with web applications with complicated UI: lots of complex forms with dozens of fields and interactivity (when you select an item in a combobox, another combobox will get new values, some fields will be pre-filled, a part of the form will disappear or change and so on). DotVVM是一个 MVVM 框架,特别适用于具有复杂 UI 的 Web 应用程序:许多复杂的表单,具有数十个字段和交互性(当您在组合框中选择一个项目时,另一个组合框将获得新值,一些字段将被预填充,表单的一部分将消失或更改等)。 Modal dialogs, multi-step wizards, lots of grids with data, sorting, paging...模态对话框、多步骤向导、大量带有数据的网格、排序、分页......

Because DotVVM handles many things for you and translates the data-bindings to JavaScript, you don't need to write the JS yourself.因为 DotVVM 会为您处理很多事情并将数据绑定转换为 JavaScript,所以您不需要自己编写 JS。 It doesn't mean that you should not learn it.这并不意味着你不应该学习它。 It will help you a lot if you know it - you will be able to add even more interactivity, extend the framework when you need it and more.如果您知道它,它将对您有很大帮助 - 您将能够添加更多交互性,在需要时扩展框架等等。 DotVVM lets you do quite a lot without knowing JS, but you will get much further if you know it. DotVVM 可以让你在不了解 JS 的情况下做很多事情,但如果你知道它,你会走得更远。


Angular, React or other client-side frameworks are used widely today and many websites and applications are built in that. Angular、React或其他客户端框架在今天被广泛使用,许多网站和应用程序都内置在其中。 They are more universal than DotVVM, which aims primarily at the business app segment and requires .NET on the server (because it is not only the client-side library).它们比 DotVVM 更通用,DotVVM 主要针对业务应用程序部分,并且需要服务器上的 .NET(因为它不仅仅是客户端库)。

Using Angular or React requires the knowledge of JavaScript, and not only that.使用 Angular 或 React 需要 JavaScript 知识,不仅如此。 You will need to know Node.js and the related tooling, like npm.您需要了解 Node.js 和相关工具,例如 npm。 You will need to exchange data with the server, so you will need to build probably a REST API, use Swagger to generate the client-side proxy classes, and then you will probably need some other JS libraries with controls and things like that.您将需要与服务器交换数据,因此您可能需要构建一个 REST API,使用 Swagger 生成客户端代理类,然后您可能需要一些其他带有控件和类似内容的 JS 库。

It is quite a lot of things to learn and if you are used to the comfort of Visual Studio, like the IntelliSense or the debugger, you will miss these features for sure.要学习的东西很多,如果您习惯了 Visual Studio 的舒适性,例如 IntelliSense 或调试器,您肯定会错过这些功能。


And finally, you don't need to stick to one technology.最后,您不需要坚持一种技术。 You can combine Razor Pages with DotVVM for example.例如,您可以将 Razor Pages 与 DotVVM 结合使用。 You can make the admin dashboard in DotVVM and the public part of the website in Razor Pages.您可以在 DotVVM 中制作管理仪表板,在 Razor Pages 中制作网站的公共部分。

Microsoft is coming back to the WebForms approach to simplify the project structure trusting in the "Convention over configuration" mantra, while hiding the configuration from developer to make things faster.微软正在回归 WebForms 方法来简化项目结构,相信“约定优于配置”的口号,同时对开发人员隐藏配置以加快速度。 But it has the disavantage that everything will be mixed again.但它的缺点是一切都会再次混合。 I doesn't look like a smart move for organizing.我看起来不像是组织的明智之举。 But... Hey!但是……嘿! Something new must catch the attention of the dev towards Microsoft.一些新的东西必须引起开发人员对微软的注意。

If your page uses an MVC Web API for the REStful, it's really more easy to just use Razor pages.如果您的页面将 MVC Web API 用于 RESTful,那么仅使用 Razor 页面确实更容易。 If not, I would recommend you to use Core MVC.如果没有,我建议您使用 Core MVC。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM