Skip to content

Commit 0fd9346

Browse files
committed
fb
1 parent 6a51fb7 commit 0fd9346

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Mvc/Mvc.Core/src/ModelBinding/Binders/BodyModelBinder.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.IO;
99
using System.Text;
1010
using System.Threading.Tasks;
11+
using Microsoft.AspNetCore.Http.Features;
1112
using Microsoft.AspNetCore.Mvc.Core;
1213
using Microsoft.AspNetCore.Mvc.Formatters;
1314
using Microsoft.AspNetCore.Mvc.Infrastructure;
@@ -143,8 +144,9 @@ public async Task BindModelAsync(ModelBindingContext bindingContext)
143144

144145
if (formatter == null)
145146
{
146-
if (AllowEmptyBody && httpContext.Request.ContentLength == 0)
147+
if (AllowEmptyBody && httpContext.Features.Get<IHttpRequestBodyDetectionFeature>()?.CanHaveBody == false)
147148
{
149+
bindingContext.Result = ModelBindingResult.Success(model: null);
148150
return;
149151
}
150152

0 commit comments

Comments
 (0)