@@ -24,7 +24,7 @@ internal class NotFoundSelectorPolicy : MatcherPolicy, IEndpointSelectorPolicy
24
24
public NotFoundSelectorPolicy ( EndpointDataSource endpointDataSource )
25
25
{
26
26
_notFound = new Lazy < Endpoint > ( GetNotFoundEndpoint ) ;
27
- _endpointDataSource = endpointDataSource ;
27
+ _endpointDataSource = endpointDataSource ;
28
28
}
29
29
30
30
// return the endpoint for the RenderController.Index action.
@@ -46,7 +46,7 @@ public bool AppliesToEndpoints(IReadOnlyList<Endpoint> endpoints)
46
46
{
47
47
// Don't apply this filter to any endpoint group that is a controller route
48
48
// i.e. only dynamic routes.
49
- foreach ( Endpoint endpoint in endpoints )
49
+ foreach ( Endpoint endpoint in endpoints )
50
50
{
51
51
ControllerAttribute controller = endpoint . Metadata ? . GetMetadata < ControllerAttribute > ( ) ;
52
52
if ( controller != null )
@@ -61,7 +61,7 @@ public bool AppliesToEndpoints(IReadOnlyList<Endpoint> endpoints)
61
61
62
62
public Task ApplyAsync ( HttpContext httpContext , CandidateSet candidates )
63
63
{
64
- if ( candidates . Count == 1 && candidates [ 0 ] . Values == null )
64
+ if ( AllInvalid ( candidates ) )
65
65
{
66
66
UmbracoRouteValues umbracoRouteValues = httpContext . Features . Get < UmbracoRouteValues > ( ) ;
67
67
if ( umbracoRouteValues ? . PublishedRequest != null
@@ -72,8 +72,20 @@ public Task ApplyAsync(HttpContext httpContext, CandidateSet candidates)
72
72
httpContext . SetEndpoint ( _notFound . Value ) ;
73
73
}
74
74
}
75
-
76
- return Task . CompletedTask ;
75
+
76
+ return Task . CompletedTask ;
77
+ }
78
+
79
+ private static bool AllInvalid ( CandidateSet candidates )
80
+ {
81
+ for ( int i = 0 ; i < candidates . Count ; i ++ )
82
+ {
83
+ if ( candidates . IsValidCandidate ( i ) )
84
+ {
85
+ return false ;
86
+ }
87
+ }
88
+ return true ;
77
89
}
78
90
}
79
91
}
0 commit comments