如何在asp.netcore-spa应用程序上禁用服务器端渲染? [英] How to disable server side rendering on an asp.netcore-spa application?

查看:54
本文介绍了如何在asp.netcore-spa应用程序上禁用服务器端渲染?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用aspnetcore-spa react-redux样板构建应用程序(可以在解决方案

该模板将asp-prerender-module标记助手添加到Home\Index.cshtml中的<div id="react-app"...>标记.如果删除该标记帮助器,则将禁用服务器端呈现.

标签帮助程序已导入/Views/_ViewImports.cshtml:

@addTagHelper "*, Microsoft.AspNetCore.SpaServices"

在使用...运行应用程序之前,可以从命令行进行捆绑.

> webpack --config webpack.config.vendor.js
> webpack

史蒂夫·桑德森(Steve Sanderson)在NDC悉尼就此发表了演示.

aspnet-prerender-module 标记助手是 SpaServices 的一部分,这是Yeoman aspnetcore-spa 模板生成的所有项目的基础.因此,这就是您在任何这些模板(包括Angular 2AureliaKnockoutReact (with Redux))中启用/禁用预渲染的方式.这同样适用于使用Node aspnet-prerendering 创建的任何自定义项目或模板. a>和上述标记帮助器.

I am building my application using aspnetcore-spa react-redux boilerplate (can be seen on http://blog.stevensanderson.com/2016/05/02/angular2-react-knockout-apps-on-aspnet-core/ )

However the server side rendering takes a lot of time (~30 sec) and I would like to disable it. Can you please tell me how to disable server side rendering without breaking the code?

解决方案

That template adds the asp-prerender-module tag helper to the <div id="react-app"...> tag in Home\Index.cshtml. If you remove that tag helper you will disable server side rendering.

The tag helper is imported in /Views/_ViewImports.cshtml:

@addTagHelper "*, Microsoft.AspNetCore.SpaServices"

You can do the bundling from the command line before you run the application with...

> webpack --config webpack.config.vendor.js
> webpack

Steve Sanderson gave a presentation on this at NDC Sydney.

The aspnet-prerender-module tag helper is part of SpaServices, which is the basis for all the projects generated by the Yeoman aspnetcore-spa templates. Therefore, this is how you would enable/disable pre-rendering in any of those templates, including Angular 2, Aurelia, Knockout, and React (with Redux). The same would apply to any custom project or template that you create using Node package aspnet-prerendering and the aforementioned tag helper.

这篇关于如何在asp.netcore-spa应用程序上禁用服务器端渲染?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆