Reputation: 12656
I have a Web API 2 controller. I am sending a JavaScript Object from the client in a call:
myObject = {propertyOne: 'Hi', propertyTwo: 'Bye'}
Do I HAVE to make a class with those properties in C# to receive the object as an argument to the Web API controller?
public void controllerMethod(myObject object)
{
}
Is there away to AVOID making an object that will only be used to receive data? If so, how?
Upvotes: 0
Views: 44
Reputation: 1805
the below would work, but not recommended.
public void controllerMethod(dynamic myObject)
{
}
Among a number of benefits, it's a positive security benefit to create an object and bind it so that you can't get extra properties posted in from an attacker that are not intended to be there.
Upvotes: 1