When I use the FromForm
and BindProperty
attributes, or even only parameters in the method, I get the same result, both get the values that were sent from a form. Is there any difference between using one or the other?
Some Web API examples:
Attribute FromForm
:
public string Example { get; set; }
[HttpPost]
public async Task<IDictionary<string, object>> PostAsync([FromForm] string example)
{
Example = example;
WITHOUT attribute FromForm
(parameter only):
public string Example { get; set; }
[HttpPost]
public async Task<IDictionary<string, object>> PostAsync(string example)
{
Example = example;
Attribute BindProperty
:
[BindProperty]
public string Example { get; set; }
[HttpPost]
public async Task<IDictionary<string, object>> PostAsync()
{