![]() ![]() In addition to the (many) limitations of static prerendering that I described in my previous post, you should be aware that we're not doing anything fancy here. Pages Īnd that's all there is to it - you can now add routable components as necessary, and you don't have to worry about updating them in the test project too. The following is the .cs file, tidied up slightly, and with various #pragma and other symbols removed // namespace BlazorApp1. #ALL THAT REMAINS PART 1 OVERRIDE CODE#g.cs, contain the code for your Razor components. For my sample app, these were found in obj/Debug/net5.0/Razor/Pages/: You can find these files buried deep in the obj folder of your project after you build. cs files generated for each of the components. The easiest approach is to examine the intermediate. The only difference between the components is the directive in the first case. razor file, for example: "/test"īut what does this actually do? To see what the impact of the directive was, I created two components, TestComponent1.razor, which contains the code above, and TestComponent2.razor which contains the code below: Test ![]() You can create a "routable" component in Blazor using the directive, and adding a route template to the top of your. Comparing routable Razor components with standard components #ALL THAT REMAINS PART 1 OVERRIDE HOW TO#In this post, I show how to improve that with a little bit of. One of the downsides of the approach in my previous post was that you had to manually list the routes to prerender as data for a Theory test: public async Task Render ( string route ) When combined with the additional WebAssembly publish output, we get: The final output of the prerendering stage was the following, in which the index, counter and fetch-data pages have been rendered as HTML index.html files nested inside the appropriate folder. In my previous post I described an approach that uses the TestHost to render all the pages in a sample Blazor WebAssembly app to HTML. This removes the need for a host app, though the approach has various limitations. With static prerendering you render all of the pages in your application to raw HTML at build time. In my previous post I discussed the desire for static prerendering of a Blazor WebAssembly app, so that you could host the app using static file hosting. Typically, you need to use a "host" ASP.NET Core application to prerender a Blazor WebAssembly app, as I described in a recent post: It is useful (among other reasons) for improving the perceived speed of a client-side app. Prerendering is where a client-side application is rendered on the server as part of the initial response. Recap: static prerendering for WebAssembly apps In this post I show one way to find all the routes in your application using a bit of reflection. One of the downsides of the approach in that post, is that you have to manually list all of the routes in your app, so the prerenderer can generate each page. ![]() In my previous post I showed how you could statically prerender all the routable components in your Blazor WebAssembly app ahead-of-time so that you could host your app in static-file hosting. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |