-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Initial Form-binding support #44653
Initial Form-binding support #44653
Conversation
@brunolins16 any reason this is a draft? |
Nope. I was waiting before I have all checks green to make it ready for review. 😬 |
Please take a look 🙏@BrennanConroy @captainsafia @halter73 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we care if someone accesses the same form data from multiple parameters? I assume it would just work because we are just reading indexes from an already created collection.
RequestDelegateFactoryContext factoryContext) | ||
{ | ||
// Do not duplicate the metadata if there are multiple form file parameters | ||
if (!factoryContext.ReadFormFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very familiar with how forms work, but is there any way to have this code path run and register just "multipart/form-data", then have one of the other paths run which would normally add "application/x-www-form-urlencoded" as well, but now they won't because we set ReadForm
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if I get your question correctly but, while might be possible send file using application/x-www-form-urlencoded
(i am not very familiar 🤷♂️ ) . The FormFeature
only read files from a multipart/form-data
request.
else if (HasMultipartFormContentType(contentType)) |
My approach here is to keep not adding duplicated metadata, however, since we don't know the parameter ordering and we process them sequentially, in case we found a IFormFile
or IFormFileCollection
an additional is added, for the first parameter only, with multipart/form-data
and since the last metadata is the most relevant it should basically this one been used, make sense?
It just works. if I am not wrong, we are calling |
parameter, | ||
valueExpression, | ||
factoryContext, | ||
"form file"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: make this a constant?
@brunolins16 where's the issue for this PR? |
@davidfowl #39430. I decided no close it because we need to investigate the complex types support but I should have updated the description to include what we have already. |
Hi @brunolins16. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context. |
General design:
[FromForm]
required)IFormCollection
is supported and the source will be inferredFromFromAttribute.Name
not supportedT[]
) whereT
supportsTryParse
string[]
andStringValues
Accepts
metadata (application/x-www-form-urlencoded
/multipart/form-data
)multipart/form-data
only when also includeIFromFile
orIFormFileCollection
Examples
Contributes to #39430