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
Apache License 2.0
5.62k stars 2.14k forks source link

Question: Should non-`ValueType` action parameters _always_ be non-`null`? #4971

Closed dougbu closed 8 years ago

dougbu commented 8 years ago

objects are created for unbound POCO parameters only when using ComplexTypeModelBinder. This leads to the following inconsistent behaviours:

Empty collections are created in most unbound and IsTopLevelObject cases due to activation code in CollectionModelBinder, HeaderModelBinder et cetera. But byte[] arrays are often left null e.g. when the corresponding <input/> was left blank.

The question is whether we should address these inconsistencies in 1.1.0. Should certainly check how earlier Web API and MVC releases handle the above cases. But might decide these inconsistencies are warts regardless. Or could split the scearios into "API" and "view" groups, then make separate decisions for each.

Eilon commented 8 years ago

What's the actual problem here? What observed behavior is odd, unusual, or difficult to work with?

Eilon commented 8 years ago

The first bullet point is handled by the associated bug.

The second bullet point doesn't seem concerning.

The third bullet point already has the right behavior: if no file is provided, there's no data. That seems to provide the best developer experience.