Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 888
JohnDiGriz Avatar asked Sep 19 '25 17:09

JohnDiGriz


1 Answers

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,
    };

}
like image 186
Dave Neufeld Avatar answered Sep 21 '25 08:09

Dave Neufeld