Skip to content

[Announcement] Obsoleting Microsoft.AspNetCore.SpaServices and Microsoft.AspNetCore.NodeServices #12890

Closed

Description

@danroth27

ASP.NET Core supports integration with various single-page app (SPA) frameworks, including Angular, React, and React + Redux. Initially integration with these frameworks was accomplished with ASP.NET Core specific components that handled scenarios like server-side prerendering and integration with webpack. But as time went on, industry standards changed and the SPA frameworks each released their own standard command-line interfaces (e.g., Angular CLI, create-react-app).

When ASP.NET Core 2.1 was released in May 2018, we responded to the change in standards by providing a newer and simpler way to integrate with the SPA frameworks' own toolchains. This new integration mechanism exists in the package Microsoft.AspNetCore.SpaServices.Extensions and remains the basis of our Angular and React project templates since ASP.NET Core 2.1.

To clarify that the older ASP.NET Core specific components are not relevant or recommended, we are now officially obsoleting the pre-2.1 integration mechanism and marking the supporting NPM packages as deprecated.

The contents of the following NuGet packages have all been unnecessary since ASP.NET Core 2.1, and so are now being marked as obsolete:

  • Microsoft.AspNetCore.SpaServices
  • Microsoft.AspNetCore.NodeServices

For the same reason, the following NPM modules are being marked as deprecated:

  • aspnet-angular
  • aspnet-prerendering
  • aspnet-webpack
  • aspnet-webpack-react
  • domain-task

These packages will later be removed in .NET 5. If you are using these packages, please update your apps to use the functionality in Microsoft.AspNetCore.SpaServices.Extensions instead along with the functionality provided by the SPA frameworks you are using. To enable features like server-side prerendering and hot module reload please refer to the documentation for the corresponding SPA frameworks. The functionality in Microsoft.AspNetCore.SpaServices.Extensions is not obsolete and will continue to be supported.

Activity

  1. added
    area-mvc
    on Aug 5, 2019
  2. added this to the Discussions milestone on Aug 5, 2019
  3. NotMyself commented on Aug 6, 2019

    @NotMyself

    Is UseWebpackDevMiddleware going away with this change? Or UseSpaStaticFiles?

  4. flcdrg commented on Aug 6, 2019

    @flcdrg
    Contributor

    We've been using Microsoft.AspNetCore.NodeServices as a way of executing JavaScript in Node on the server from .NET Core - specifically by calling the InvokeAsync method(s).

    We'd previously been using the ClearScript library (in an earlier .NET Framework project), but that does not yet support .NET Core/.NET Standard.

    If Microsoft.AspNetCore.NodeServices goes away, our only alternative would probably be to fork the source code.

  5. CodeTherapist commented on Aug 6, 2019

    @CodeTherapist

    Is UseWebpackDevMiddleware going away with this change? Or UseSpaStaticFiles?

    @NotMyself As far as I understand UseWebpackDevMiddleware will go away and UseSpaStaticFiles will not.

    Seriously, I liked this webpack middleware with HMR, because it accelerates the inner loop and is more comfortable instead of having two processes (dev server + ASP.NET Core app). It also reflects more the production running app - that is served by ASP.NET Core using e.g. Kestrel.
    I use it with vuejs (started with this obsoleted template).

    I would appreciate, when useful libraries aren't become obsolete after years of supporting it. That weaknesses the trust using a library. At least, I expect a comprehensive migration guide for those who using the obsolete libraries.

  6. Simon-Bull commented on Aug 6, 2019

    @Simon-Bull

    We use the ISpaPrerenderer.RenderToString() functionality to server render a VueJS application, passing application context with the customDataParameter.

    Is there a recommended migration path to move to functionality in Microsoft.AspNetCore.SpaServices.Extensions? This seems to use RenderToString() itself.

  7. bugproof commented on Aug 6, 2019

    @bugproof

    Any reason why there's no official vue project template?

  8. CodeTherapist commented on Aug 6, 2019

    @CodeTherapist

    Any reason why there's no official vue project template?

    @bugproof Maintaining templates isn't effortless. This has been discussed in issue: aspnet/JavaScriptServices/issues/412.

  9. Sebazzz commented on Aug 6, 2019

    @Sebazzz

    So how would HMR work with Webpack now? Webpack runs its own web server.

  10. ericgreenmix commented on Aug 6, 2019

    @ericgreenmix
    Contributor

    My company also uses the Microsoft.AspNetCore.NodeServices to execute JS from .Net. Is there a recommended alternative, if NodeServices is going away?

  11. alexdresko commented on Aug 6, 2019

    @alexdresko

    I get the main gist of this issue, but losing UseWebpackDevMiddleware seems unfortunate. It works great for frameworks that don't have a CLI.

  12. atrauzzi commented on Aug 6, 2019

    @atrauzzi

    I'm not sure I understand how NodeServices is related to this? What if people want to run JS code from C# for their own purposes?

  13. NotMyself commented on Aug 6, 2019

    @NotMyself

    @alexdresko I agree with you. UseWebpackDevMiddleware is a nice compromise to supporting multiple frameworks. I have been using it for around a year to do Vue.js development, example. It works quite nicely.

  14. 296 remaining items

  15. 1kevgriff commented on Feb 19, 2021

    @1kevgriff

    Might be worth keeping an eye on this issue: #27887

  16. Luiz-Monad commented on Feb 22, 2021

    @Luiz-Monad

    If you write F#, you can use https://fable.io/ to create isomorphic applications and share code between server and client.
    This way you take backend code used for server-side rendering and compile it to JS and run inside node, instead of doing this hack of running node from aspnet core.
    In some cases, you can run that and make it work barely enough to extract HTML and CSS from things like Material-UI.

  17. rjgotten commented on Feb 22, 2021

    @rjgotten

    @Luiz-Monad

    this hack

    All the existing NodeServices does and is, is a thin layer of child process lifetime management and an HTTP loopback to facilitate communication.

    The messy parts - and the only reason Microsoft could conceivably use as proper arguments to drop support - are in the JavaScript glue-code such as the aspnet-webpack NPM package, the state of which I've expounded on before. There's nothing wrong with the approach on principle and it is honestly quite architecturally sound.

    I wouldn't exactly resort to calling a fairly standard and well-understood practice of inter-process communication over an HTTP loopback a 'hack' when compared to shoe-horning your entire application into an isomorphic rendering model that can fit yet another compiles-down-to-javascript cross-compiler. But maybe that's just me.

  18. Luiz-Monad commented on Feb 23, 2021

    @Luiz-Monad

    I wouldn't exactly resort to calling a fairly standard and well-understood practice of inter-process communication over an HTTP loopback a 'hack' when compared to shoe-horning your entire application into an isomorphic rendering model that can fit yet another compiles-down-to-javascript cross-compiler. But maybe that's just me.

    That's not the part that was a hack, its totally valid to use HTTP to do IPC between two different processes, The hack-part was the way it was starting the node server from inside that library.
    I would much prefer something I control directly from the infrastructure side, like in docker or something, than starting gratuitous process in my production environment.

  19. brunolau commented on Feb 23, 2021

    @brunolau

    For anyone needing mostly the UseWebpackDevMiddleware extension method - I've attempted to port the Microsoft.AspNetCore.SpaServices library into .NET 5 by using the https://github.com/JeringTech/Javascript.NodeJS library.

    Migration path:

    1. Install the BrunoLau.SpaServices NuGet package
    2. Change using Microsoft.AspNetCore.SpaServices.Webpack; to using BrunoLau.SpaServices.Webpack;
    3. Change UseWebpackDevMiddleware to UseWebpackDevMiddlewareEx

    That should do the trick...I've also attempted to port the Prerendering part, however as I've never used it and don't have time to learn just to test something I'll probably never use in production I haven't tested it

    Source available on https://github.com/brunolau/BrunoLau.SpaServices

  20. rjgotten commented on Feb 24, 2021

    @rjgotten

    @Luiz-Monad
    The hack-part was the way it was starting the node server from inside that library.

    Ah. If that's your beef, then iirc you can reconfigure the services collection with replacement classes that don't create a new node process and interface with it over local loopback, but which connect to an already running node process elsewhere.

    Those parts should be replaceable as iirc one of the in-the-box replacements was to not use HTTP loopback but use named pipes.

  21. vslzl commented on Feb 24, 2021

    @vslzl

    Hello there, can anyone suggest a proper way to use ssr with recent versions of both asp.net and angular? for development I tried sth but for deployment it's not working at all. My old application was net core 3.1 with angular 11 works wit ssr but now I'm desperate...

  22. brunolau commented on Feb 24, 2021

    @brunolau

    @vslzl if you were using the Microsoft.AspNetCore.SpaServices library, you might try my port which is mentioned 2 comments above

  23. alekkowalczyk commented on Feb 24, 2021

    @alekkowalczyk

    @vslzl seems that the proper way is to split such app into ASP.NET back-end and node.js front-end for SSR, just wondering if there is an easy way to deploy such bundle into a single Azure AppService? 🤔

  24. vslzl commented on Feb 25, 2021

    @vslzl

    @vslzl if you were using the Microsoft.AspNetCore.SpaServices library, you might try my port which is mentioned 2 comments above

    I'll try, thank you.

    @vslzl seems that the proper way is to split such app into ASP.NET back-end and node.js front-end for SSR, just wondering if there is an easy way to deploy such bundle into a single Azure AppService? 🤔

    Exactly, I don't want to split my application in two parts. Single Pain Application is enough. No need to double them.

  25. mopinsk commented on Feb 26, 2021

    @mopinsk

    You can create directories within your Azure AppService and make them virtual applications.
    I've created a directory 'webapi' which serves requests to the '/webapi' endpoint (ASP.Net Core Web API, .Net 5) and a 'client' directory for my Angular SSR client (Angular 11), which serves everything but 'webapi'.
    For node.js in an Azure AppService you need to enable the iisnode module in your web.config (which you can find in the 'deploy a node.js app to azure AppService' tutorial.

  26. alekkowalczyk commented on Feb 26, 2021

    @alekkowalczyk

    You can create directories within your Azure AppService and make them virtual applications.
    I've created a directory 'webapi' which serves requests to the '/webapi' endpoint (ASP.Net Core Web API, .Net 5) and a 'client' directory for my Angular SSR client (Angular 11), which serves everything but 'webapi'.
    For node.js in an Azure AppService you need to enable the iisnode module in your web.config (which you can find in the 'deploy a node.js app to azure AppService' tutorial.

    Interesting, how is it set-up in the dev environment? Is it within one csproj? How does the deployment look like, possible through a single "Publish" from Visual Studio?

  27. mopinsk commented on Feb 26, 2021

    @mopinsk

    I don't have access to my development environment right now but I can give more information about my setup next week.
    For publishing: I use Azure DevOps where I created a CI/CD pipeline that publishes whatever I have changed (either Angular Client or ASP.Net Core Web API, or both) to the AppService.

  28. mopinsk commented on Mar 7, 2021

    @mopinsk

    You can create directories within your Azure AppService and make them virtual applications.
    I've created a directory 'webapi' which serves requests to the '/webapi' endpoint (ASP.Net Core Web API, .Net 5) and a 'client' directory for my Angular SSR client (Angular 11), which serves everything but 'webapi'.
    For node.js in an Azure AppService you need to enable the iisnode module in your web.config (which you can find in the 'deploy a node.js app to azure AppService' tutorial.

    Interesting, how is it set-up in the dev environment? Is it within one csproj? How does the deployment look like, possible through a single "Publish" from Visual Studio?

    I have finally had some time to create a repository and set up a little demo consisting of:

    • ASP.NET Core Web API (.NET 5)
    • Angular 11 Client with SSR (using Angular Universal w/ Express running in IIS/Azure by using iisnode)
    • GitHub Action to build and deploy to Azure Web App

    You can find my repo here: https://github.com/mopinsk/aspnetcore-angular-ssr
    If you have any questions, feel free to open an issue in the repo. Hope I could help.

  29. ghost locked as resolved and limited conversation to collaborators on Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changefeature-spa

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions