简体   繁体   中英

Asp.net hosted multiple blazor apps

I dividing my website into multiple blazor apps in which each module should be routed by a sub path eg: products module should be accessed by the url "domain/products" etc.

so in the configure method in my asp.net core server project when calling

app.UseBlazor<Products.Startup>()

whats the proper way to rout all the single page app url through "domain/products/*"

thanks

You can host your blazor app in a sub folder with:

app.Map("/subfolder", child => { child.UseBlazor<Blazor.Program>(); });

And change the basepath of your blazor app in the index.html like this:

<base href="/subfolder/" />

If your like me that's looking for this now, this will get you what you need (as far as I can tell)

            app.Map("/site1", app =>
            {
                app.UseRouting();
                app.UseAuthorization();
                app.UseClientSideBlazorFiles<Site1.Startup>();
                app.UseEndpoints(endpoints =>
                {
                    endpoints.MapFallbackToClientSideBlazor<Darixidor.Site.Startup>("index.html");
                });
            });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM