We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6a51fb7 commit 0fd9346Copy full SHA for 0fd9346
src/Mvc/Mvc.Core/src/ModelBinding/Binders/BodyModelBinder.cs
@@ -8,6 +8,7 @@
8
using System.IO;
9
using System.Text;
10
using System.Threading.Tasks;
11
+using Microsoft.AspNetCore.Http.Features;
12
using Microsoft.AspNetCore.Mvc.Core;
13
using Microsoft.AspNetCore.Mvc.Formatters;
14
using Microsoft.AspNetCore.Mvc.Infrastructure;
@@ -143,8 +144,9 @@ public async Task BindModelAsync(ModelBindingContext bindingContext)
143
144
145
if (formatter == null)
146
{
- if (AllowEmptyBody && httpContext.Request.ContentLength == 0)
147
+ if (AllowEmptyBody && httpContext.Features.Get<IHttpRequestBodyDetectionFeature>()?.CanHaveBody == false)
148
149
+ bindingContext.Result = ModelBindingResult.Success(model: null);
150
return;
151
}
152
0 commit comments