MVC Web Api difference between HttpPost and HttpPut
No attribute can make your methods unique when you have 2 methods with the same name and the same signature.
The solution in your case would look something like this.
[HttpPost]
public bool User(userDTO postdata)
{
return dal.addUser(postdata);
}
[HttpPut]
[ActionName("User")]
public bool UserPut(userDTO postdata)
{
return dal.editUser(postdata);
}
P.S: The convention for naming methods is that you should use PascalCase and use verbs when naming your methods.
Method Naming Guidelines
MVC Web Api difference between HttpPost and HttpPut
An HTTP PUT
is supposed to accept the body of the request, and then store that at the resource identified by the URI
.
An HTTP POST
is more general. It is supposed to initiate an action on the server. That action could be to store the request body at the resource identified by the URI
, or it could be a different URI, or it could be a different action.
PUT is like a file upload. A put to a URI affects exactly that URI. A POST to a URI could have any effect at all.
already defines a member called user with the same parameter types
You can't have multiple methods with the same signature within the same scope like that i.e. same return type and parameter type.
[HttpPost]
public bool User(userDTO postdata)
{
return dal.addUser(postdata);
}
[HttpPut]
[ActionName("User")]
public bool UserPut(userDTO postdata)
{
return dal.editUser(postdata);
}
more related ans. check this . GET and POST methods with the same Action name in the same Controller