Matching Action Method Parameters
In this lesson, we will learn how to pass parameters to action methods, taking them from various parts of the current request and from application internal sources.
We'll cover the following...
Action method parameters can be filled with information from various sources. In previous lessons, we have seen three of them: route parameters, query-string, and form fields.
By default, parameters that are simple types are taken from the route parameters and query-string, while complex types with several properties and collections are bound with data extracted from the request body. By default, no other sources are considered, but we can force the usage of specific sources with parameters’ attributes.
Value lookup and parameters’ attributes
We can force the source to be used for filling a parameter with an attribute that precedes a parameter.
The table below describes all options:
Attribute | Example | Source |
---|---|---|