This is a development of a question that I asked earlier that changed into a different problem.
My Web API 2 controller is successfully being hit, but the view model passed as a parameter is not being populated. It contains nulls for strings and falses for booleans.
My controller looks like this:
[HttpPost]
public IEnumerable<string> Post(SearchParameters id)
{
return null;
}
public struct SearchParameters
{
string brokerIsUnallocated;
string brokerIncludeDeleted;
string businessType;
bool codeC;
bool codeD;
bool codeP;
bool codeS;
bool codeT;
bool codeX;
string companyName;
string contactName;
string country;
string customerId;
string department;
string selectedBroker;
string town;
}
I have checked in Fiddler and every parameter is being passed. Do I somehow need to pass this as a parameter called ID to match the controller action? I am using the default routing, like this:
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
Fiddler request looks like this:
Looking forward to your responses.