1

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

2 Answers 2

1

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/" />

Sign up to request clarification or add additional context in comments.

5 Comments

is there any way to keep the href of the base tag unchanged
Not that I know of, it is needed for routing, so maybe if you are not using that
because changing href would for example make accessing apis endpoints either harder or imposipple
No, not at all. You can happily use any url for your backend calls, I'm doing that all the time. The base href in index.html has no effect on that.
app.Map(...) part is no more applicable in the latest version. Only changing the <base href="/subfolder/" /> is required.
0

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");
                });
            });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.