Fix FromHybrid for query data with no body

This commit is contained in:
Laura Hausmann 2024-01-30 19:33:32 +01:00
parent 12a18987b0
commit a734583b15
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -39,7 +39,7 @@ public class HybridModelBinder(
) : IModelBinder { ) : IModelBinder {
public async Task BindModelAsync(ModelBindingContext bindingContext) { public async Task BindModelAsync(ModelBindingContext bindingContext) {
if (bodyBinder != null && bindingContext is if (bodyBinder != null && bindingContext is
{ IsTopLevelObject: true, HttpContext.Request.HasFormContentType: false }) { { IsTopLevelObject: true, HttpContext.Request: { HasFormContentType: false, ContentLength: > 0 } }) {
bindingContext.BindingSource = BindingSource.Body; bindingContext.BindingSource = BindingSource.Body;
await bodyBinder.BindModelAsync(bindingContext); await bodyBinder.BindModelAsync(bindingContext);
} }