diff --git a/src/Mvc/Mvc.RazorPages/src/Infrastructure/PageActionDescriptorProvider.cs b/src/Mvc/Mvc.RazorPages/src/Infrastructure/PageActionDescriptorProvider.cs index f1dc8bd237..23a449e731 100644 --- a/src/Mvc/Mvc.RazorPages/src/Infrastructure/PageActionDescriptorProvider.cs +++ b/src/Mvc/Mvc.RazorPages/src/Infrastructure/PageActionDescriptorProvider.cs @@ -107,10 +107,6 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure descriptor.RouteValues.Add("page", model.ViewEnginePath); } - // Mark all pages as a "dynamic endpoint" - this is how we deal with the compilation of pages - // in endpoint routing. - descriptor.EndpointMetadata.Add(new DynamicEndpointMetadata()); - actions.Add(descriptor); } } @@ -143,10 +139,5 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure // Combine transformed page route with template return AttributeRouteModel.CombineTemplates(transformedPageRoute, pageRouteMetadata.RouteTemplate); } - - private class DynamicEndpointMetadata : IDynamicEndpointMetadata - { - public bool IsDynamic => true; - } } } \ No newline at end of file diff --git a/src/Mvc/Mvc.RazorPages/src/Infrastructure/PageLoaderMatcherPolicy.cs b/src/Mvc/Mvc.RazorPages/src/Infrastructure/PageLoaderMatcherPolicy.cs index 6ff7ceb1c9..d8b274e826 100644 --- a/src/Mvc/Mvc.RazorPages/src/Infrastructure/PageLoaderMatcherPolicy.cs +++ b/src/Mvc/Mvc.RazorPages/src/Infrastructure/PageLoaderMatcherPolicy.cs @@ -33,12 +33,11 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure throw new ArgumentNullException(nameof(endpoints)); } - if (!ContainsDynamicEndpoints(endpoints)) - { - // Pages are always dynamic endpoints. - return false; - } - + // We don't mark Pages as dynamic endpoints because that causes all matcher policies + // to run in *slow mode*. Instead we produce the same metadata for things that would affect matcher + // policies on both endpoints (uncompiled and compiled). + // + // This means that something like putting [Consumes] on a page wouldn't work. We've never said that it would. for (var i = 0; i < endpoints.Count; i++) { var page = endpoints[i].Metadata.GetMetadata();