Universal: Hosting on IIS

Created on 4 Aug 2017  路  12Comments  路  Source: angular/universal

Hello,

I have been watching the topic of server-side rendering/prerendering for a long time now. I have a Windows server and I need to host my Angular website on IIS, for many reasons. I am also using Angular-CLI which I like very much and I want to keep using it.

As far as I could read the solution for IIS hosting is to host the app inside an ASP.NET project. That is literally the LAST thing I will do, I think it's a very bad choice and Microsoft is just trying to push their tools to Angular Developers.

Another solution would be to run in an Node Express server, but that for me is not a good choice for a production environment. I need to set multiple host headers and I need to change them dynamically, which (I think) is not possible with Express. Is there a way to host the site in IIS under Windows?

The solution that I am leaning towards right now is to use prerendering to pre-render my site altogether. However, because my pages will be dynamic I need to have the possibility to update the indexed pages dynamically. So I need a way to at least reindex a single route, ideally from inside the Angular application or from the backend. What tool should i use for this task?

PS: IMHO, it would be nice to have Angular Universal as web server extension, like an ISAPI extension or an Apache module. This would make it much easier to host.

Most helpful comment

Ok, now that we got that out of the way i'm hoping for a solution :)

All 12 comments

Ditching IIS will solve a lot of your issues :)

Ok, now that we got that out of the way i'm hoping for a solution :)

This is what I unsuccessfully attempted to do: https://stackoverflow.com/questions/40625354/server-side-rendering-angular-2-in-asp-net-with-edge-js

I was basically trying to make a call to Node using Edge.js to render from an ASP.NET MVC project (which was not .NET Core). I got a proof of concept working, and I actually sort of got it to render (though the rendered output was only accessible via an error object for some reason, and it seemed like I had to wait for a timeout after 10 minutes or so). That was many months ago, so who knows, maybe that approach would be more viable now.

Did you try iisnode?

@gbrossi Thank you, I will try that, did not know of its existance.

Will there be support for Angular Universal on .Net MVC?

If iisnode is not a case for you, you might want to look at dotnet core angular template, but still you will be forced to setup dotnet core hosting tools for this to run

I wanted to bump this thread with both our own solution which was not ideal and keep tabs on it for something a little better.

For me, IIS wasn't a choice i get to make... IT choose the server, we make it work as best we can. In the end we ended up doing something i really don't like but it works

IIS running IIS Node handler which i use to run an Express server... following this https://blog.pusher.com/make-angular-4-app-seo-friendly/ as a general guiding rod after that.

It would be great i could skip the IISNode requirement and that there was perhaps someone with more .NET talent than I who could create some copy paste friendly solution to the web.config and perhaps a mini app + config to manage the pre-rendering universal work.

We also looked elsewhere like prerender.io which does have a much easier setup for other servers to get the same job done , buts its a paid for solution... i much prefer the universal path.

For what I know while looking around, botnet implementation of universal is still requires node js, yep it does not requires iis node, but it seems that you gonna need it in either case. Hope that helps

Could you link me something re:

botnet implementation of universal

I'd be much obliged, i saw something about using firebase and universal, not sure if its related or not to what you're eluding to. Cheers.

I'm speaking about this one - https://github.com/angular/universal/blob/master/modules/aspnetcore-engine/README.md

it is mentioned in readme, and at moment guys are rewriting it to support cli

So that means that the only way to server-side render a Angular app in IIS is through a ASP.NET Core?

Was this page helpful?
0 / 5 - 0 ratings