Multiple Blazor Projects in the Same Web Application
Asked Answered
D

1

7

I want to separate a large development project into smaller projects, so I can manage and build separately. This is so that my team to work on separate parts of a Web application by working on separate projects. I want to have Multiple Visual Studio Blazor Projects Participate in the Same Web Application, so that multiple Visual Studio projects share the same IIS application root directory. I need this because it is easier to manage smaller units of a large Web application, to build each project separately from the other projects (which shortens the build times during development), and to divide a large Web application into logical units and have these units share common resources, such as controls. I want to have a root Blazor project http://localhost/MainWeb, that can use child (subweb) projects http://localhost/MainWeb/subweb

Demoss answered 23/12, 2019 at 8:11 Comment(9)
The guide is not meant for Blazor.Demoss
So you want single-signon or just a unified URL structure?Saez
It's not entirely clear what you are asking. Can it be two separate csproj's, but just share the same base url?Slade
I want to have one root Blazor project, that can use fully functionally pages from other child blazor projects.Demoss
@Demoss It sounds like you might be looking for Razor Class Libraries? learn.microsoft.com/en-us/aspnet/core/blazor/…Slade
I agree with Kobra. A single large application is harder to maintain, deploy, develop etc. It is better to have multiple small projects (call them microservices if you will), that can be deployed independently but share the same entry point (single URL). Each of those small projects could have UI and logic for specific functionality. It would be great to see a working example for this.Ait
@Demoss did you find a way? I have the same needDandruff
@VAAA, I could notDemoss
I'm confused. Don't you just make a Razor class library?Verge
H
2

In Blazor Server I think I've found a partial (experimental) solution using "AdditionalAssemblies" directive in "<Router" in App.razor, as stated in this article:

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

Other info here: https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/routing?view=aspnetcore-6.0#route-to-components-from-multiple-assemblies

I've initially created a main project, that is my app only with its main menu which serves only for login and routing purposes, then I've created other projects of type "RazorComponent" (so not a standalone app) containing the single logical unit (for example the customers anagraphical data management) and for the routing to them (managed by the menu in the initial main app) I've used the "AdditionalAssemblies" (as in the above link). This way I register in IIS the main app (as usual) and then distribute in the same folder the dlls created by the single logical units (that are the RazorComponents) generated by the single projects and routed by the main app. I wanted anyway the same behavior requested by the original poster, that is each single logical unit to be seen as a single app site and navigated directly through browser address, but until now this is the only solution I've found to have separated projects for a single application.

Huberthuberto answered 15/8, 2022 at 20:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.