Background and Motivation
#10317 identifies an issue where the behavior of the AuthorizationMiddleware circumvents the filter logic in SkipStatusCodeAttribute and results in the StatusCodePageMiddleware being executed when it shouldn't and masking the underlying 401 from the AuthorizationMiddleware.
This PR attempts to resolve this issue by removing the dependency on the IFilter execution order from the SkipStatusCodeAttribute by introducing an ISkipStatusCodesMetadata interface.
Proposed API
namespace Microsoft.AspNetCore.Http.Metadata;
public interface ISkipStatusCodePagesMetadata
{
bool Enabled { get; }
}
- public class SkipStatusCodePagesAttribute : Attribute, IResourceFilter
+ public class SkipStatusCodePagesAttribute : Attribute, IResourceFilter, ISkipStatusCodePagesMetadata
{
+ public bool Enabled { get; }
}
Usage Examples
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", [SkipStatusCodePages] (c) =>
{
c.Response.StatusCode = 404;
return Task.CompletedTask;
});
});
PR located at #38509
Background and Motivation
#10317 identifies an issue where the behavior of the
AuthorizationMiddlewarecircumvents the filter logic inSkipStatusCodeAttributeand results in theStatusCodePageMiddlewarebeing executed when it shouldn't and masking the underlying 401 from theAuthorizationMiddleware.This PR attempts to resolve this issue by removing the dependency on the
IFilterexecution order from theSkipStatusCodeAttributeby introducing anISkipStatusCodesMetadatainterface.Proposed API
Usage Examples
PR located at #38509