Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Conversation

SteveSandersonMS
Copy link
Member

@SteveSandersonMS SteveSandersonMS commented Sep 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.

@SteveSandersonMS
Copy link
Member Author

I'm going to merge this straight away because some other template work can't proceed until we get CI builds of the updated SpaServices package.

But this is still very much open to review and possible changes/reversions.

@SteveSandersonMS SteveSandersonMS merged commit c47d5bf into dev Sep 29, 2017
@SteveSandersonMS SteveSandersonMS deleted the stevesa/new-spa-apis branch September 29, 2017 12:56
.Properties.Keys.OfType<AngularCliMiddleware>().FirstOrDefault();
if (angularCliMiddleware == null)
{
throw new Exception(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Framework Design Guidelines: DO NOT throw Exception or SystemException.

// for prerendering that returns complete HTML pages
if (renderResult.Globals != null)
{
throw new Exception($"{nameof(renderResult.Globals)} is not supported when prerendering via {nameof(UsePrerendering)}(). Instead, your prerendering logic should return a complete HTML page, in which you embed any information you wish to return to the client.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Framework Design Guidelines: DO NOT throw Exception or SystemException.

message += "Your application is running in Production mode, so make sure it has been published, or that you have built your SPA manually. Alternatively you may wish to switch to the Development environment.\n";
}

throw new Exception(message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Framework Design Guidelines: DO NOT throw Exception or SystemException.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants