Reputation: 125
Is there a way to host 2 blazor server apps in one ASP Core project, so that I have one executable/process, which exposes the two different apps on different ports?
I know, that I can restrict routes via .RequireHost("*:8080")
to a specific port, but I can't get my head around, how to do this with two blazor server side rendering apps.
Thanks in advance!
Upvotes: 1
Views: 900
Reputation: 125
So I figured it out:
In __host.cshtml
use the following code to decide, which app should be loaded:
@switch(HttpContext.Request.Host.Port)
{
case 1234:
<component type="typeof(App1)" render-mode="ServerPrerendered"/>
break;
case 4321:
<component type="typeof(App2)" render-mode="ServerPrerendered"/>
break;
}
Upvotes: 4