Add SPA middleware APIs to support new templates #394

Closed
opened 2025-08-09 17:16:07 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @SteveSandersonMS on 9/29/2017

These new APIs allow for a more modern way to host a SPA inside an ASP.NET application:

  • Instead of prerendering being done through a tag helper that executes when rendering an MVC view, prerendering can now be applied as root-level middleware independent of any MVC concepts.
    • This means it works just the same in Razor Pages sites as in MVC sites.
    • In this mode, the prerenderer is expected to return a complete HTML page rather than just an HTML fragment, which better matches what people want to do with more recent SPA technologies such as Angular CLI.
  • Instead of SPA fallback routing being done as an MVC route, it can now be applied as another root-level middleware that returns a "default page" for the SPA.
    • This is simpler and again it better matches more recent SPA technologies.
    • Plus it allows a new notion of SPA-related middleware that specifically modify how the "default page" is generated - for example it might be generated by Webpack Dev Middleware or Angular CLI.
  • The dev-time middleware is no longer limited to Webpack. This PR also adds support for Angular CLI to act as alternative dev-time middleware to return dynamically built client-side resources.

None of these changes should affect backward compatibility. Existing SPA applications built with the current templates can continue to work fine and don't need to be updated.

*Originally created by @SteveSandersonMS on 9/29/2017* These new APIs allow for a more modern way to host a SPA inside an ASP.NET application: * Instead of prerendering being done through a tag helper that executes when rendering an MVC view, prerendering can now be applied as root-level middleware independent of any MVC concepts. * This means it works just the same in Razor Pages sites as in MVC sites. * In this mode, the prerenderer is expected to return a complete HTML page rather than just an HTML fragment, which better matches what people want to do with more recent SPA technologies such as Angular CLI. * Instead of SPA fallback routing being done as an MVC route, it can now be applied as another root-level middleware that returns a "default page" for the SPA. * This is simpler and again it better matches more recent SPA technologies. * Plus it allows a new notion of SPA-related middleware that specifically modify how the "default page" is generated - for example it might be generated by Webpack Dev Middleware or Angular CLI. * The dev-time middleware is no longer limited to Webpack. This PR also adds support for Angular CLI to act as alternative dev-time middleware to return dynamically built client-side resources. None of these changes should affect backward compatibility. Existing SPA applications built with the current templates can continue to work fine and don't need to be updated.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#394
No description provided.