BankMan101
BankMan101

Reputation: 281

Blazor specify the Href of a menu item to be a page in another project

I have a Blazor server solution using

Microsoft.AspNetCore.App.Ref v6.0.0 and blazor mudblazor 6.10.0

. The solution has two projects ProjectA and ProjectB, ProjectA has all the Blazor scaffolding code and ProjectB has some additional Blazor pages and components which I want to use and reference from ProjectA.

ProjectA has a MudNavMenu in which it has a menu item which should point to a component in ProjectB it is defined as follows

<MudNavLink Href="/modelrange/model1"

Inside ProjectB there is a Razor Page inside the Folder structure Pages/ModelRange/index.razor

With a route definition as follows

@page "/modelrange/model1"

When I click on the link I get an error stating that

there's nothing at this address.

I have tried adding this to the startup.cs of ProjectA but with no luck

services.AddRazorPages().AddApplicationPart(Assembly.Load("ProjectB"));

Upvotes: 1

Views: 178

Answers (1)

Ruikai Feng
Ruikai Feng

Reputation: 11896

You have to modify your App.razor:

<Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="new[] {your target assembly}">
 .........
</Router>

Here's the document realted

It's ok on myside: enter image description here

Upvotes: 2

Related Questions