New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add metadata types for form reading and mapping options #49844
Labels
api-approved
API was approved in API review, it can be implemented
area-minimal
Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
area-mvc
Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Milestone
Comments
captainsafia
added
the
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
label
Aug 3, 2023
dotnet-issue-labeler
bot
added
the
needs-area-label
Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically
label
Aug 3, 2023
captainsafia
added
area-mvc
Includes: MVC, Actions and Controllers, Localization, CORS, most templates
api-ready-for-review
API is ready for formal API review - https://github.com/dotnet/apireviews
area-minimal
Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
and removed
api-suggestion
Early API idea and discussion, it is NOT ready for implementation
needs-area-label
Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically
labels
Aug 3, 2023
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
API Review Notes:
API Approved! // Assembly: Microsoft.AspNetCore.Http.Abstractions;
namespace Microsoft.AspNetCore.Http.Metadata;
public class FormMappingOptionsMetadata(int? maxCollectionSize = null, int? maxRecursionDepth = null, int? maxKeySize = null)
{
public int? MaxCollectionSize { get; } = maxCollectionSize;
public int? MaxRecursionDepth { get; } = maxRecursionDepth;
public int? MaxKeySize { get; } = maxKeySize;
}
public interface IFormOptionsMetadata
{
bool? BufferBody { get; }
int? MemoryBufferThreshold { get; }
long? BufferBodyLengthLimit { get; }
int? ValueCountLimit { get; }
int? KeyLengthLimit { get; }
int? ValueLengthLimit { get; }
int? MultipartBoundaryLengthLimit { get; }
int? MultipartHeadersCountLimit { get; }
int? MultipartHeadersLengthLimit { get; }
long? MultipartBodyLengthLimit { get; }
}
// Assembly: Microsoft.AspNetCore.Routing;
namespace Microsoft.AspNetCore.Builder;
public static class RoutingEndpointConventionBuilderExtensions
{
public static TBuilder WithFormMappingOptions<TBuilder>(this TBuilder builder,
int? maxCollectionSize = null,
int? maxRecursionDepth = null,
int? maxKeySize = null) where TBuilder : IEndpointConventionBuilder { }
// Defaults map to pre-existing values throughout framework
public static TBuilder WithFormOptions<TBuilder>(this TBuilder builder,
bool? bufferBody = null,
int? memoryBufferThreshold = null,
long? bufferBodyLengthLimit = null,
int? valueCountLimit = null,
int? keyLengthLimit = null,
int? valueLengthLimit = = null,
int? multipartBoundaryLengthLimit = null,
int? multipartHeadersCountLimit = null,
int? multipartHeaderLengthLimit = null,
int? multipartBodyLengthLimit = null) where TBuilder : IEndpointConventionBuilder { }
} // Assembly: Microsoft.AspNetCore.Mvc.Core;
namespace Microsoft.AspNetCore.Mvc;
- public class RequestFormLimitsAttribute : Attribute, IFilterFactory, IOrderedFilter {}
+ public class RequestFormLimitsAttribute : Attribute, IFilterFactory, IOrderedFilter, IFormOptionsMetadata {} |
halter73
added
api-approved
API was approved in API review, it can be implemented
and removed
api-ready-for-review
API is ready for formal API review - https://github.com/dotnet/apireviews
labels
Aug 7, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
api-approved
API was approved in API review, it can be implemented
area-minimal
Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
area-mvc
Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Background and Motivation
To support full parity between the existing anti-forgery support in MVC and the new anti-forgery middleware, we need to support a metadata-based approach for configuring limits to be used when reading from a form. Also, we need to introduce a mapping options type to support configuring the binding experience for forms.
Proposed API
Usage Examples
Alternative Designs
For .NET 8, we're intentionally moving with the model of having separate form mapping options types for Blazor and minimal APIs, even though they have the same form mapping infrastructure. The goal is to unify these options types in .NET 9 into a new assembly, but for now, the
FormMappingOptionsMetadata
is defined only as a concrete implementation and not an interface since we don't anticipate evolving it further in .NET 8 before we unify the two types.Risks
There are risks and costs to action.
The text was updated successfully, but these errors were encountered: