简体   繁体   中英

Is it possible to load blazor pages (not components) from RCL without changing App.razor?

I am trying to create an blazor assembly that should be installed as a nuget package. The idea is to load the blazor pages as if they where on an endpoint route, and this should be done by extension methods on startup.cs (net5)/ program.cs (net6) only.

The regular solution is to add AdditionalAssemblies on Router component inside App.razor.

<Router
    AppAssembly="typeof(Program).Assembly"
    AdditionalAssemblies="new[] { typeof(Component1).Assembly }">
    ...
</Router>

Is there a way to achieve the same from an extension method called by startup.cs or program.cs?

Check my repo, shows different ways to load RCL to a project, the only limitation today is to register dynamically a DI from the component library

https://github.com/elgransan/BlazorPluginComponents

I added an example for loading a RCL as a Page dynamically

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM