For creating Web API project open your Visual Studio Editor and Create New Project as shown in below figure.
Thursday, 3 September 2020
Creating First WEB API Project from scratch ?
Difference between WCF and Web API ?
Firsty We have to Understand What is WCF ? WCF stands for Windows Communication Foundation is also used for creating RestFul and Non Restful services like SOAP Services.WCF is mainly used for creating services that are protocol independent or transport independent. For example if we have a scenario in which we have two clients one is .NET client and other one is JAVA client and both the clients want to access a single WCF service with diffrent protocol and message formates like JAVA Client wants Transport Protocol as HttP and message format XML for his simplicity whereas .NET Client want transport protocol to be TCP and message formate to be Binary for the performance point of view so in this scenario we Create a Single WCF service with two endpoints one for each client.
Below figure shows Single WCF Service with two End Points.
WCF does not provides any MVC type support whereas Web API supports MVC type architecture support.
WCF is best suitable choice if you are using .NET 3.5.
WCF supports multiple transport protocols like TCP,UDP and Named Pipes.Whereas WEB API supports only HTTP Protocols only.
WEB API supports convention based CRUD operations with the help of HTTP Verbs like GET,PUT,POST and Delete.
WEB API provides support for Content Negotiation like provides choice for JSON/XML/Other Formates for response.
WEB API is Tightly coupled with HTTP.
WCF is better options when you want Serialization for the data over the network.
WCF has rich data contract and it is easy to self hosting.
WEB API is completely Open Source so it is better choice for creating Restful Services over the .NET Framework.
ASP.Net WEB API Introduction
What is ASP.NET Web API ? Firsty We have to Understand What is API ? API Stands for "Application Programming Interface" is a set of software or piece of code which perform some specific task and provides response in Universal format like (JSOn/XML/Other Formates) and It uses Client Server Constraints , In which Client sends request to the Server for specific data defined into the Header and Server Process on the request and sends Response back to the Client. So Client perform his/her specific task without interering from the server side and vise versa is also true.
Here Client may a Browser or it may be Console Application or it may be a web application User Interface or It may a Mobile Device or it may be IoT type things also.
ASP.NET Web API :- ASP.NET Web API is a Http based service built on the top of the .NET Framework and these services deployed anywhere on Internet and accessed by the clients like Browsers,Mobile Applications,Desktop Applications and IoT devices. It is Independent Software Architecture that use Http protocol for sending and receiving data. It has a Client Server architecture in which Client sends request and server process on that request and sends response back to the server in the Universal format like Json/XML/other formates.
ASP.Net Web API Sketch Diagram is shown below.
Explanation of above diagram :- In the above diagram we have write WebAPI for showing details for voters based on the Areacode and we deployed this Web API on https://emsanalysis.com on the Internet. In the above figure there are four clients which are accessing these Web API by sending request https://emsanalysis.com/VoterDetails?AreaCode=12356 to server. Server process on the request and response back to clients like Desktop Application,Mobile Devices,Iot,and Browsers. Response contains JSON data or XML data or any other formates which specify into the header and according to response data client parse the data and display it. The most common use of Web API is to build Restful Services.</strong> So now question is what is Restful Services ? REST stands for Representational State Transfer is an architectural pattern that is mainly used for creating API that is based on HTTP protocol.
REST includes some rules that is used for creation of API, which includes
Client Server Pattern
StateLess Requests
Cacheability for Data
HTTP Verbs for Communication
HTTP verbs are the predefined set of rules which is used for accessing these resources so there are mainly used VERBS are
GET
PUT
POST
DELETE
POST is used for sending some data to server so we can add data into the body of message. so POST is generally send data for save or process data on server according to it.
PUT is used for sending some data to server for update data based on the conditions or data appended into the body of message. In simple we can say that it is UPDATE operation for WEB API.
DELETE is used for delete some data from the database server based on the key values appended into the URL or we can say that it is DELETE operation for WEB API.
Creating First WEB API Project from scratch ?
For creating Web API project open your Visual Studio Editor and Create New Project as shown in below figure. Now you have to select ASP.N...
-
Data Navigations means send data from one web forms to another web forms . There are six data navigation techniques are present in the ASP....
-
As you know all the configuration settings are present into the web configuration file . In this file we are learning about how to add con...
-
ADO.Net : ADO Stands for Microsoft Activex Data Object is a set of Classes (frameworks) is used as a intermediatory part between any Dot N...