Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Placing some razor pages in a different assembly - blazor

Like to have some of the razor pages as blazor components in a different assembly, What is the procedure and best-practice to do this?

BlazorComponents --> Type of Razor Class Library, I placed counter.razor here

BlazorServerApp

In the Imports I imported the @using BlazorComponents namespace, but when running seems still doesn't have access to counter page via /counter

Using all the latest versions.

like image 470
Kasrak Avatar asked Jan 25 '23 08:01

Kasrak


1 Answers

Taken from the Microsoft docs here - https://learn.microsoft.com/en-us/aspnet/core/blazor/routing?view=aspnetcore-3.1

Use the AdditionalAssemblies parameter to specify additional assemblies for the Router component to consider when searching for routable components. Specified assemblies are considered in addition to the AppAssembly-specified assembly. In the following example, Component1 is a routable component defined in a referenced class library. The following AdditionalAssemblies example results in routing support for Component1:

<Router
    AppAssembly="typeof(Program).Assembly"
    AdditionalAssemblies="new[] { typeof(Component1).Assembly }">
...
</Router>
like image 157
Rob Avatar answered Feb 15 '23 01:02

Rob