I’m upgrading from .NET classic to .NET Core 8 on a backend – it would be preferable to not have to change the frontend (even if it would be far better, this is beyond the scope of this project which is large enough as it is).
-----------------------------223163892637736061113378850953
Content-Disposition: form-data; name="SubscriptionFinAccountID"
null
The model looks like this:
public class SettingsModel
{
...
public int? SubscriptionFinAccountID { get; set; }
}
The controller method looks like this:
[HttpPost(nameof(SaveAccountSettings))]
public IActionResult SaveAccountSettings([FromForm]DefaultAccountSettings model)
The Property SubscriptionFinAccountID is a nullable int. However, the null in the Form-Data is treated like a string and thus cannot be converted to an int value.
Is there a way to override the model binding when using the [FromForm] attribute?
(The result above should be that the property SubscriptionFinAccountID should be set to null instead of throwing a parsing error which is the default)