Lawraoke
Lawraoke

Reputation: 556

C# received [HTTPPOST] request

for C# WebApi, I used this function to deal with the POST request from my front end, code as below Method1:

[HttpPost]
public object GetPostItem(string Name, string email, int Code)
{
  //perform something here
}       

but it seems like it didn't work, unless I try for Method2

[HttpPost]
public object GetPostItem(info Info)
{
  //This is how I get them from *Info*
  info.Name
  info.email
  info.Code
  //perform something here
}     

Is there any way for letting function POST to received object separately or the only way to deal with POST is Method2 ?

Upvotes: 1

Views: 72

Answers (1)

Leszek Mazur
Leszek Mazur

Reputation: 2531

At most one parameter is allowed to read from the message body. And body is default source in post. You can use parameters by FromUri Attribute.

Upvotes: 1

Related Questions