This repository was archived by the owner on Feb 25, 2021. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Just for the sake of it, its still working and relevant. (Original #238)
[WIP] Prerendering (#24)
How does it work
When ever a request comes in that would result in returning the content of
index.html
, the prerendering kicks in and replaces theapp
tag with the prerendered content.In detail
app.UseBlazorPrerendering<TEntryComponent>("app", configure => {});
in the server project.TEntryComponent
will be the component to get prerendered and inserted into theapp
tag.UseBlazorPrerendering
attaches theBlazorPrerenderingMiddleware
to theISpaBuilder
, to intercept requests toindex.html
.index.html
. Theindex.html
is parsed withAngleSharp
, and modified to contain the prerendered content. This implementation is almost 100% the same as the one inIndexHtmlFileProvider
.Renderer
. This implementation for the most part is identical to the one inBrowserRenderer.ts
. But it only supports the initial creation, since update on the serverside does not make sense. Also when encountering aComponent
it goes into recursion, which is different from the Browser version.What is in this PR
Microsoft.AspNetCore.Blazor.Server.Rendering project
Contains all things related to prerendering
PreRenderer
implementation ofRenderer
(needs cleanup)PrerenderingApp sample
Current Limitations
IUriHelper
implementationPreUriHelper
of methodGetBaseUriPrefix
harcoded to match server url.It only works with theapp
tag. There should be some way to define the entry component. Also it would be nice to have different services (which also means different references) on server vs client side.As of now i can only imaging 3 projects.One containing the ComponentsOne for bootstrapping in BrowserOne for bootstrapping in ServerNo way to supply services to prerendering. It would be nice to be able to supply different services while prerendering. This would allow to reuse server services to prerender the content without issuing http calls on the server side.What now?
I know the issue #24 is not yet assigned to any version. And maybe this implementation is going completely haywire. I just did what i thought might be the general idea. Either way, this was major fun.
Let me know what you think!