Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/Umbraco.Web.Website/Routing/EagerMatcherPolicy.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Routing;
Expand Down Expand Up @@ -126,8 +126,20 @@ public async Task ApplyAsync(HttpContext httpContext, CandidateSet candidates)
return;
}

// If it's an attribute routed IVirtualPageController with a Host attribute we should ignore if the host doesn't match the current request.
// Maybe we would expect that it wouldn't be in the provided CandidateSet, but it will be included just based on the Route.
// See: https://github.com/umbraco/Umbraco-CMS/issues/16816
if (controllerTypeInfo is not null && controllerTypeInfo.IsType<IVirtualPageController>())
{
HostAttribute? hostAttribute = controllerTypeInfo.GetCustomAttribute<HostAttribute>();
if (hostAttribute is not null && hostAttribute.Hosts.InvariantContains(httpContext.Request.Host.Value) is false)
{
continue;
}
}

// If it's an UmbracoPageController we need to do some domain routing.
// We need to do this in oder to handle cultures for our Dictionary.
// We need to do this in order to handle cultures for our Dictionary.
// This is because UmbracoPublishedContentCultureProvider is ued to set the Thread.CurrentThread.CurrentUICulture
// The CultureProvider is run before the actual routing, this means that our UmbracoVirtualPageFilterAttribute is hit AFTER the culture is set.
// Meaning we have to route the domain part already now, this is not pretty, but it beats having to look for content we know doesn't exist.
Expand Down