How web API works in asp.net
Loading
How web API works in asp.net
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Naimish MakwanaPosted Apr 15, 2024, 4:21 AM
ASP.NET Web API is a framework for building HTTP services that can be accessed from any client including browsers and mobile devices1. Here’s a high-level overview of how it works:
Application Layer: The Web API is a framework for building web services that use the HTTP protocol. The Web API returns data on request from the client, which can be in XML or JSON format2.
MVC Architecture: The MVC (Model-View-Controller) architecture is used for isolating an application to simplify testing and maintenance of the application’s code2.
Web API Architecture: The Web API uses the HTTP protocol. The selection of the action in the Web API uses the HTTP method instead of the URI path2. It uses a Routing table that defines the action to be called for which request2. The routing parameters are specified in the
webApiConfig.csfile2.Here’s an example of how the routing is configured:
And here’s how you can define the code to illustrate how the routing is configured by the action:
The Web API Framework matches the segments in the URI path to the template2. After the selection of the controller, the Web API selects the action by calling the
IHttpActionSelector.SelectAction2.Here’s an example of a Web API controller:
You can also use other HTTP methods, such as POST, PUT, or DELETE2. If you want to override the Action Name, you can do so using the Action Name Attribute2.
Thanks