Web API 1
Web API 1
0
By
Amareswar Rao
A valid response is returned to the client, and information from the request can
be included.
When the type has a void return type, a value of 204 is automatically
transmitted back to the client.
HttpPost
Post operations should be named with a prefix of Post.
To match the correct controller, the Web API adds the literal
Controller to the controller variable.
HttpPost HttpPut
System.Web.Http.AcceptVerbsAttribute
http://localhost:PORTNUMBER/api/Controller/Customers/1
http://localhost:PORTNUMBER/api/Controller/Customers/GetCustomers/1
http://localhost:PORTNUMBER/data/Customer/SearchCustomers?
lastName=r (ERROR)
http://localhost:PORTNUMBER/data/Customer/FindCustomers?
lastName=r (No ERROR)
NonActions
Any Controller method defined with the public access modifier is accessible
by default. There are certainly times when you might need to have the
member typed with the public modifier but dont want it exposed to clients.
In these cases, simply annotate each such method with the NonAction
attribute, and it will be explicitly prevented from being invoked.
Appropriate formats for
responses
Request contains something called an Accept header , which
specifies the type of data that you as a client expect from the server
Accept: text/html,application/xhtml+xml,application/xml
By default, Web API works with both JSON and XML data.