Remove dynamic from page endpoints

This commit is contained in:
Ryan Nowak 2019-04-16 10:07:23 -07:00 committed by Ryan Nowak
parent 6f305373ca
commit 7021df89e4
2 changed files with 5 additions and 15 deletions

View File

@ -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;
}
}
}

View File

@ -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<PageActionDescriptor>();