Callum
❔ Load Blazor components from a string
Hi All,
I've tried to Google this before however not to much success... In essence the scenario is that I'm building a CMS in which currently blocks of HTML & JavaScript are loaded onto the page from a database as the server effectively "mimics" a full page structure by when you request a page, effectively pulling from the database the HTML for the page and writing it onto the page...
As far as I'm aware Blazor is compiled, however I wanted to know if there is a way to load a dynamic Blazor component from a string during runtime of my application and be able to render that on the page... So I may start with a Blazor SPA and then receive a string which contains a Blazor component that I then need to shove onto the page...
Any suggestions would be very very helpful and appreciated!
I'm aware that it's considered anti-pattern to store code in a database however it is the path of least resistance as I feel other ways would be that I'd need to download all the stuff out of the database, build it, then deploy it out, or potentially build 17 different web applications as the CMS is a standard web platform. And then any time the consumer of the CMS wants to make a change it'd then have the overhead of having a very long build process before it'd be available which may result in impatience from the customer...
So basically in essence
Render Page -> Inject Blazor component -> Render blazor component...
Thanks!
7 replies