Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

server side rendering is not working in angular universal in iis

I referred https://github.com/angular/universal-starter and have implemented in angular5.server side rendering is not working after hosting in iis.It is fine in localhost:4000

Thanks

like image 546
kamalav Avatar asked Mar 22 '18 09:03

kamalav


People also ask

Can Angular render on server-side?

To implement server side rendering in your Angular application, you can use the Angular Universal package.

Is not defined Angular universal?

This error can be caused by a reference to the Window object if you are rendering your application from a server like Node. js. I will share how I have solved this issue, in my case this was caused by HammerJS which does not support server-rendered applications.

Is Angular framework client-side or server-side?

Angular applications are client-side applications that execute on the browser - which means they are rendered on the client, not on the server. You can add server-side rendering to your app using Angular Universal.


1 Answers

Use JavaScriptServices for ASP.NET. It provides:

Microsoft.AspNetCore.SpaTemplates plugs into dotnet new, providing project templates for Angular 2, Aurelia, Knockout, React, and React+Redux applications. Microsoft.AspNetCore.SpaServices is how SpaTemplates-produced projects work internally. It provides useful features for SPA applications, such as server-side rendering for Angular and React applications, plus integration with Webpack build middleware. Microsoft.AspNetCore.NodeServices is how SpaServices works internally. It’s a low-level library that gives a fast, robust way for ASP.NET Core applications to run arbitrary JavaScript code on the server.

TUTORIAL

#Server-side-prerendering

aspnetcore-angular2-universal. After running it,I got Child compilation failed error

@kamalav, I tested it locally.

Requirements: Make sure you have at least Node 6.x or higher (w/ npm 3+) installed! This repository uses ASP.Net Core 2.0, which has a hard requirement on .NET Core Runtime 2.0.0 and .NET Core SDK 2.0.0. Please install these items from here

  1. npm install
  2. npm run build:dev
  3. dotnet restore
  4. dotnet run
like image 111
Yerkon Avatar answered Nov 15 '22 01:11

Yerkon