Fix #3068 - support microsites in .NET MAUI

This commit is contained in:
sbwalker
2023-08-02 13:55:01 -04:00
parent 122fcfd701
commit 7a42646bed
20 changed files with 144 additions and 91 deletions

View File

@ -22,6 +22,7 @@ namespace Oqtane.Infrastructure
var config = context.RequestServices.GetService(typeof(IConfigManager)) as IConfigManager;
string path = context.Request.Path.ToString();
if (config.IsInstalled() && !path.StartsWith("/_blazor"))
{
// get alias (note that this also sets SiteState.Alias)
@ -43,6 +44,14 @@ namespace Oqtane.Infrastructure
});
context.Items.Add(Constants.HttpContextSiteSettingsKey, sitesettings);
// handle first request to site
var serverState = context.RequestServices.GetService(typeof(IServerStateManager)) as IServerStateManager;
if (!serverState.GetServerState(alias.SiteKey).IsInitialized)
{
var sites = context.RequestServices.GetService(typeof(ISiteRepository)) as ISiteRepository;
sites.InitializeSite(alias);
}
// rewrite path by removing alias path prefix from reserved route (api,pages,files) requests for consistent routes
if (!string.IsNullOrEmpty(alias.Path))
{