JohnDiGriz
JohnDiGriz

Reputation: 191

App not finding Razor page located in another project

I'm working on Razor Pages Project. This solution consists of multiple projects, namely "Server", which manages services for dependency injection and is a startup project. "App" which contains Index page and shared Components, and multiple "Module" projects that are independent areas of a site. I need to add new module to this solution, with landing page. I created new project, set all references to other projects in solution, and created a page there with "@page "/moduleC"" line. But if I run solution and go to that page - it shows 404 page. Same configuration works fine with other modules. Is there some additional actions required to allow routing between multiple projects?

Upvotes: 4

Views: 2462

Answers (2)

Dave Neufeld
Dave Neufeld

Reputation: 71

https://digitteck.com/frontend/blazor/blazor-page-in-another-assembly/

The Router component is responsible for mapping the razor pages.

You will need to add the other assemblies using the AdditionalAssemblies parameter.

<CascadingAuthenticationState>
    <Router AppAssembly="@typeof(Program).Assembly" AdditionalAssemblies="@_extraAssemblies">
        <Found Context="routeData">
           ...
        </Found>
        <NotFound>
            ...
        </NotFound>
    </Router>
</CascadingAuthenticationState>

@code{

    private List<System.Reflection.Assembly> _extraAssemblies = new List<System.Reflection.Assembly>()
    {
        typeof(OtherProject.SomeObjectInOtherProject).Assembly,
    };

}

Upvotes: 7

Learner
Learner

Reputation: 51

I assume you are working on Blozor app. If my guess is correct , please import the reference inside the _Import.razor in your Balzor.WebAssembly or Balzor.Server project.

Example

@using <--ProjectName-->.ComponentsLibrary
@using <--ProjectName-->.ComponentsLibrary.<--ComponentName-->

Upvotes: 0

Related Questions