Due to limitations imposed by a hosting provider, I am forced to use ASP.NET Core 1.1.
I have created a model class and wish to have that model bind to a named value that is different to the name of the model property.
In ASP.NET Core 2.0 onward, I would use the BindPropertyAttribute as follows:
public class MyModel
{
[BindProperty(Name="g-recaptcha-response")]
public string GoogleReCaptchaResponse { get; set; }
}
However, the BindPropertyAttribute is not supported in ASP.NET Core 1.1. Is there an alternative I can use instead?
You can use
ModelBinderattribute :In the view , you should set the element
nametog-recaptcha-responsefor model binding: