When posting a form with a POCO object and FormCollection object to a Controller Action a SystemMethodException occurs. This was working fine in RC1 but since the upgrade to RC2 the exception started.
Here is the part of the Action:
// POST: Candidate/Create
[Authorize]
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create(Candidate candidate, FormCollection obj, IList<IFormFile> files)
{
var auser = await _userManager.FindByNameAsync(User.Identity.Name);
var employee = _employeeService.GetEmployee(auser.Id);
if (employee != null && employee.PartnerId != null)
{
ViewBag.PartnerId = employee.PartnerId;
}
...
}
This should be IFormCollection instead of FormCollection, we intentionally dropped support for the concrete type here in RC2 because IFormFeature is replaceable.
That did it. Thanks.
@rynowak - does the exception message include the type that couldn't be constructed? If not, should we modify places where we call CreateInstance to try-catch and explicitly call out the object type?
We should also consider handling this within the provider. Then you'd get an error about "could not create a model binder for type foo". We don't need to do anything fancy, just have the complex type binder check for a no-arg constructor.
@fhnainia glad we could help. Let's keep the bug open for now to track and improvement in the experience when this happens.
@kichalla - please discuss with me and @dougbu before starting