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 |
BrennanConroy
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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)IFormCollectionis supported and the source will be inferredFromFromAttribute.Namenot supportedT[]) whereTsupportsTryParsestring[]andStringValuesAcceptsmetadata (application/x-www-form-urlencoded/multipart/form-data)multipart/form-dataonly when also includeIFromFileorIFormFileCollectionExamples
Contributes to #39430