Nagaraj Mani
Nagaraj Mani

Reputation: 13

angular universal with asp.net mvc

Anyone working with angular 5.0-universal with Asp.net MVC 5.0 combination ? note: we are not using asp.net core 2.0.

We are loading templateurl as {controller/action} so that we are using the razor view (cshtml) benefits. Problem here is we are unable to bundle it using webpack. Any example or reference will be helpful for us. Thanks in advance!

Upvotes: 1

Views: 825

Answers (1)

David Chelliah
David Chelliah

Reputation: 1349

You cannot use Angular Universal(SSR) with Asp.net MVC 5.0.

Because Angular universal rendering engine was written with ASP.Net Core in mind. https://github.com/angular/universal/tree/master/modules/aspnetcore-engine

And the actual magic for invoking, communicating and executing NodeJs scripts by spinning NodeJs thread from .Net webpage was implemented by aspnet .net core team through following Github project - JavascriptService. There is no backward port of this project. https://github.com/aspnet/JavaScriptServices.

So for the second half of the question: If you are concerned about the webpack bundle generate hashed filenames, then you should be able to handle it by specifying wildcard patterns for including files in your Bundle config. https://stackoverflow.com/a/46593613/2952405

Note: You need to configure your deployment task to delete the old script files "myscript.[hash].js", before deploying the new one, to avoid ASP .net from bundling duplicate copies of previous version of same js.

Following article shows how to do it with core (just for an idea) https://davidsekar.com/aspnetcore/dealing-with-hashed-filenames

Upvotes: 2

Related Questions