How to disable server side rendering on an asp.netcore-spa application?
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.
For Angular 2 project I've solved this by removing asp-prerender-module
attribute from <app>
tag in Index.schtml.