Search code examples
angularjsasp.net-coresingle-page-applicationprerender

SPA pre-rendering in Asp.net core?


How do i implement prerenderio in asp.net core, for angular spa. Or is there any way that asp.net core has introduced to do this. Actually i am migrating my old asp.net to asp.net core.


Solution

  • There is a package offered by Microsoft which allows to pre-render/execute Nodejs/JavaScript on the server side, commonly known under "JavaScriptServices". You can find it on the ASP.NET team's GitHub repository.

    There are different packages that build up on different packages. The Microsoft.AspNetCore.NodeServices is the base package, usually used for people who implement their own server-sided execution based on NodeJS. Then there is Microsoft.AspNetCore.SpaServices which is based on NodeServices and tailored for single plage applications (SPAs) and finally there is a Microsoft.AspNetCore.AngularServices package which provides Angular specific extensions and is based on SpaServices.

    On the GitHub you can find examples, for example the MusicStore SPA with server-side rendering.