As described in the introduction, this site hosts sub sites. Since some of these are run on an
ASP .NET Core hosting model, we run into a problem hosting multiple sites on one domain.
If the host site would be a
Blazor ASP .NET Core hosted model, when trying to access another sub site that also runs
ASP .NET Core we would hit a
404 error, since the host cannot find the page that is in the sub site. The host doesn’t know that the page requested is actually a sub site and has it’s own hosting model.
To counter this problem I made the host a static
HTML file that has links to the sub sites. (Other hosting models may work e.g. a
Razor pages ASP .NET Core model may work correctly since it reloads the page and doesn’t intercept the navigation as
Blazor does – I did not tested this since I wanted to host with a
With the host setup now as a static
HTML file, we still run into errors when trying to host multiple sub sites that are hosted in
ASP .NET Core here is a live example:
The problem here is that we have sibling apps that both think they own the full domain (sound familiar?!?) each site is trying to use the navigation and they both can’t run together.
The solution to this is to edit the
web.config file and tell the hosting model that it is running
OutOfProcess and therefore doesn’t have full command of the domain. It would look something like this:
<aspNetCore processPath="dotnet" arguments=".\Host.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
This enabled all the sub sites to work correctly and we no longer hit the above errors.
I wanted to test creating tabs in Blazor (to be discussed in a future post), therefore I setup the host site as a static
HTML page that shows an
iframe with full height and width. The
iframe contains a sub site that has the content I wanted to display on the home page. This causes the page to have an additional load time, since the frame only gets loaded once the rest of the page has been loaded. Since in this instance the frame is the full height and width of the page the screen remains blank until the frame has loaded.