ConvertEmptyStringToNull stopped being honored after upgrading from RC1 #4988
Description
I had a website working on ASP.NET 5 RC1 and it broke after updating to ASP.NET Core 1.0.
It depended on a property ConvertEmptyStringToNull
of class DisplayMetadata
. I'm setting it to false
for all types and properties using IDisplayMetadataProvider
, that was added to ModelMetadataDetailsProviders
collection of MvcOptions
using AddMvc()
in Startup.cs.
My case: I have a link http://localhost/Configuration/Display?ShopId=R505&Name=
I also have controller "Configuration" and action "Display" that takes a Configuration
object, which has "ShopId" and "Name" string
properties. In method Display()
I need ShopId to be "R505" and Name to be ""
(string.Empty
) in the Configuration
object. But after the upgrade the Name
property has started to come as null
. I can expand on why I need it to be an empty string, but this is probably not relevant. I'll just say that empty-string name is the default configuration for that shop, but there are also configurations with other names of course, I have no problem with those.
I also tried to apply [DisplayFormatAttribute(ConvertEmptyStringToNull = false)]
directly to the Configuration.Name
property, but it also didn't work. This property just makes no difference now. Seems like a bug.
P.S. To upgrade from RC1 I created a new blank ASP.NET Core app (so all package versions are at a default) and then added my class files from the old RC1 project, reworked Startup.cs and renamed/changed a bunch of stuff that was changed since RC1 (not very much).
I'm trying this locally in Windows 8.1 in IIS Express with Visual Studio 2015 update 3 and latest ASP.NET Core Tools installed.