本文介绍了blazor中的RenderMode.Server和RenderMode.ServerPrerendered有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两者之间有什么区别

@(await Html.RenderComponentAsync<Todo>(RenderMode.ServerPrerendered))

@(await Html.RenderComponentAsync<Todo>(RenderMode.Server))

我正在研究文档,但找不到真正能解释差异的东西.而且也不太理解枚举中的代码注释:

I was looking into the documentation but couldn't really find something that explains the difference. and also don't really understand the code comments over the enum stating:

    // Summary:
    //     Renders a marker for a Blazor server-side application. This doesn't include any
    //     output from the component. When the user-agent starts, it uses this marker to
    //     bootstrap a blazor application.
    Server = 2,
    //
    // Summary:
    //     Renders the component into static HTML and includes a marker for a Blazor server-side
    //     application. When the user-agent starts, it uses this marker to bootstrap a blazor
    //     application.
    ServerPrerendered = 3

幕后发生了什么?以及使用Server vs ServerPrerendered的方案是什么?

What is happening behind the scenes? And what are the Scenarios for using Server vs ServerPrerendered?

推荐答案

.NET Core 3.0预览版9中的ASP.NET Core和Blazor更新:

此概念与性能有关.服务页面的最快方法是静态渲染页面然后发送,而服务页面的最慢方法是服务交互式Blazor"服务器页面(具有通过SignalR websocket同步的实时虚拟DOM).

This concept is related to performance. The fastest way to serve a page is to render page statically then send, and, the slowest way to serve a page is to serve an "interactive Blazor" server page (with a live virtual DOM synchronized via SignalR websockets).

ServerPrerendered是一个折衷方案:Blazor预渲染页面并将其作为静态页面发送,然后该页面成为交互式Blazor服务器应用程序.此行为旨在通过基于时间的定位将页面快速提供给搜索引擎.

ServerPrerendered is a trade-off: Blazor pre-renders page and sends it as a static page, then later the page becomes an interactive Blazor server app. This behavior is intended to serve pages quickly to search engines with time-based positioning.

这篇关于blazor中的RenderMode.Server和RenderMode.ServerPrerendered有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 15:01