简体   繁体   English

Blazor 服务器应用程序、WebAssembly-HostedByDotNetCore 和 WebAssembly 之间的一个体面的澄清? [等候接听]

[英]A decent clarification between Blazor Server-app, WebAssembly-HostedByDotNetCore and WebAssembly? [on hold]

I've been confused about the three different options of Blazor;我一直对 Blazor 的三个不同选项感到困惑; (Server-app, WebAssembly, and WebAssembly hosted). (服务器应用程序、WebAssembly 和 WebAssembly 托管)。 Although, This Post made it mostly clear.虽然,这篇文章说得很清楚。

However, it is still unclear for me, since we can benefit both the Client-side SinglePage experience and also the Server-side features over the Blazor Server-side app, why exactly we need to use the two other options (WebAssembly and WebAssembly-hosted)?但是,我仍然不清楚,因为我们可以同时受益于客户端 SinglePage 体验和服务器端功能,而不是 Blazor 服务器端应用程序,为什么我们需要使用其他两个选项(WebAssembly 和 WebAssembly-托管)? I know that on the webAssembly-hosted option, the code will be interpreted over the webAssembly and dot.NetCore on the Client-side.我知道在 webAssembly-hosted 选项中,代码将通过客户端的 webAssembly 和 dot.NetCore 进行解释。 On the other hand, on the Server-Side app, the request sends to the Server and will be rendered and then gets back to the browser.另一方面,在服务器端应用程序上,请求发送到服务器并被渲染,然后返回到浏览器。

So by using the Blazor Server-side app, I can either keep the way of coding like MVC.Net and having different .cshtml pages, and also having a single-page part on my project.因此,通过使用 Blazor 服务器端应用程序,我既可以保持 MVC.Net 之类的编码方式并拥有不同的.cshtml页面,也可以在我的项目中使用单页部分。 (Please correct me if I'm wrong!) (如果我错了,请纠正我!)

UPDATE:更新:

Let's ask it in this way:让我们这样问:

  • On the WASM-hosted mode, the components (and its codes and other files) will be sent by the client (Browser) request, and then the browser gets (almost) all the components and files to render the pages (and also codes to be interpreted by Client-Side.Net core) on the Client-Side.在 WASM 托管模式下,组件(及其代码和其他文件)将由客户端(浏览器)请求发送,然后浏览器(几乎)获取所有组件和文件以呈现页面(以及代码到由客户端的 Client-Side.Net 核心解释)。 So now, the only network activity will be the API requests and results.所以现在,唯一的网络活动将是 API 请求和结果。
  • On the Server-side app though, you can have the normal page loads (like how it happens on MVC.Net, however using SignalR instead of Ajax) and also you can have the Single-Page mode (for instance, on the Server-Side app template, the Profile pages, send and receive data to and from the server. However, the weatherForecast and the Counter page are still Client-Side and have no further Network activity).但是,在服务器端应用程序上,您可以进行正常的页面加载(就像在 MVC.Net 上发生的那样,但是使用 SignalR 而不是 Ajax),您还可以使用单页模式(例如,在服务器上- Side app 模板,Profile 页面,向服务器发送和接收数据。但是,weatherForecast 和 Counter 页面仍然是客户端,没有进一步的网络活动)。 In this mode, again, the browser gets the files and components from the Server (Prerendered or not) and the transferred data is not as big as WASM mode and also the user is still experiencing a single-page web application which has no Network traffic since the user is working around this area.在这种模式下,浏览器再次从服务器获取文件和组件(是否预渲染),传输的数据没有 WASM 模式那么大,而且用户仍然遇到没有网络流量的单页 web 应用程序因为用户正在这个区域工作。

Honestly, client is the way to go.老实说,客户端是通往 go 的方式。 The SignalR approach with the server side is a slightly better version of asp.net with postbacks.使用服务器端的 SignalR 方法是带有回发的 asp.net 的稍好版本。

If you can take the time to learn how to use client side Blazor I think you'll be able to offer a must faster and better user experience to the user.如果您能花时间学习如何使用客户端 Blazor 我认为您将能够为用户提供更快更好的用户体验。

This is only my opinion but I think it's correct.这只是我的看法,但我认为这是正确的。

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

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