aspnet / Mvc

[Archived] ASP.NET Core MVC is a model view controller framework for building dynamic web sites with clean separation of concerns, including the merged MVC, Web API, and Web Pages w/ Razor. Project moved to https://github.com/aspnet/AspNetCore

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Regression: `ApiBehaviorOptions.SuppressInferBindingSourcesForParameters` ignored (!!)

dougbu opened this issue · comments

Is this a Bug or Feature request?

Bug and a regression. Problem does not occur with ASP.NET Core 2.1 or earlier 2.2 previews (including Preview 3).

Steps to reproduce (preferably a link to a GitHub repo with a repro project)

  1. start with https://github.com/dougbu/AspNetCoreModelBinderDemo This is a variant of https://github.com/BenjaminAbt/AspNetCoreModelBinderDemo, the repro for (closed) issue #8636
  2. set a breakpoint in MyPocoModelBinder.BindModelAsync(...)
  3. run project in VS debugger
Expected

bindingContext.BindingSource == null

Actual

bindingContext.BindingSource == BindingSource.Path
image

Description of the problem

InferParameterBindingInfoConvention has a SuppressInferBindingSourcesForParameters property which is (correctly) set from ApiBehaviorOptions.SuppressInferBindingSourcesForParameters. But, the property is never read. Parameter binding sources are always inferred in controllers with [ApiController].

Version of Microsoft.AspNetCore.Mvc or Microsoft.AspNetCore.App or Microsoft.AspNetCore.All

Microsoft.AspNetCore.Mvc: 2.2.0-rtm-35541

My thanks to @BenjaminAbt for inspiring me to take a close look at the latest code in dotnet/AspNetCore.Docs#9175 discussions