Skip to content

Enable Server Side Rendering

Asad Sahi edited this page Jan 25, 2018 · 1 revision

To enable SSR, you need to make a few changes.

  1. Uncomment these lines in Startup.cs
                          //   spa.UseSpaPrerendering(options =>
                          //    {
                          //        options.BootModulePath = $"{spa.Options.SourcePath}/dist-server/main.bundle.js";
                          //        options.BootModuleBuilder = env.IsDevelopment() ? new AngularCliBuilder(npmScript: "build:ssr") : null;
                          //        options.ExcludeUrls = new[] { "/sockjs-node" };
                          //        options.SupplyData = (requestContext, obj) =>
                          //        {
                          //          //  var result = appService.GetApplicationData(requestContext).GetAwaiter().GetResult();
                          //          obj.Add("Cookies", requestContext.Request.Cookies);
                          //        };
                          //    });

  1. Set BuildServerSideRenderer in AspNetCoreSpa.csproj file to true
    <BuildServerSideRenderer>true</BuildServerSideRenderer>
Clone this wiki locally