BeginUmbracoForm + FormCollection say use IFormCollection.. IFormCollection, dynamic, etc yields 400 errors
I have a surfacecontroller that has a method receiving a post that takes a FormCollection as a parameter.
The form is defined using a BeginUmbracoForm construct. with 5 or 6 fields. Eventually, this controller's post method will receive different models and basically record/email the information provided (hence the desire for a dynamic or a FormCollection as the parameter).
During the post, I receive this error:
InvalidOperationException: The 'Microsoft.AspNetCore.Mvc.ModelBinding.Binders.FormCollectionModelBinder' cannot bind to a model of type 'Microsoft.AspNetCore.Http.FormCollection'. Change the model type to 'Microsoft.AspNetCore.Http.IFormCollection' instead.
I have tried it using a IFormCollection, with no parameters, and with a dynamic parameter. All of these yield a 400 bad request error.
Is there a way to just receive the collection of form values? I am at somewhat of a loss because I've done the same type of thing using Umbraco8 with no issues.
public class UtilitiesSurfaceController : SurfaceController
{
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> EMailerHandler(FormCollection form )
{
I've tried it with/without the antiforgery token with no different in behavior.
BeginUmbracoForm + FormCollection say use IFormCollection.. IFormCollection, dynamic, etc yields 400 errors
I have a surfacecontroller that has a method receiving a post that takes a FormCollection as a parameter.
The form is defined using a BeginUmbracoForm construct. with 5 or 6 fields. Eventually, this controller's post method will receive different models and basically record/email the information provided (hence the desire for a dynamic or a FormCollection as the parameter).
During the post, I receive this error:
I have tried it using a IFormCollection, with no parameters, and with a dynamic parameter. All of these yield a 400 bad request error.
Is there a way to just receive the collection of form values? I am at somewhat of a loss because I've done the same type of thing using Umbraco8 with no issues.
Here is the form:
@using (Html.BeginUmbracoForm("EMailerHandler", "UtilitiesSurface")) { @Html.AntiForgeryToken()
}
Here is the footprint for the controller method:
I've tried it with/without the antiforgery token with no different in behavior.
Any ideas would be greatly appreciated;
Hi John,
Did you ever find a solution for this? I'm running into exactly the same problem.
is working on a reply...