Introduction to ASP.NET WEB API
What is ASP.NET WEB API ?
API : API stands for Application Program Interface, which has tools and protocols to develop software applications.
What is Restful ?
REpresentational State Transfer (REST) is an architectural style that has a set of configurations and properties based on HTTP(Hyper Text Transfer Protocol)
Rest Constraints :
There are few principles bound with REST architectural style:
The principles of REST are
Client-Server - Client sends the request and sever sends the response
Uniform Interface - defines Interface between client and server. here each resource is identified by URI (Uniform Resource Identifier)
Stateless - Communication between client and server should be stateless
Cacheable - Used to avoid unnecessary call backs to the server for common data required at the client over and over again
Following are the terms and frequently used in web api programming
URI can be categorized into 2 as URL and URN
URL: Uniform Resource Locator
URN: Uniform Resource Name
HTTP Content : HTTP Request and response contains the header content which specifies the message formats and other things.
Internet Media Types: MIME types are used to identity the type of the file. Internet media type is a backbone of identifying the content types on the internet.
JSON & XML :
XML stands for EXtensible Markup Language.Generally used to transport data over internet for communication between distributed applications.
Example :
<Employees>
<Employee>
<Name>Syed</Name>
<Role>Developer</Role>
</Employee>
<Employee>
<Name>Ashish Kumar Panda</Name>
<Role>Developer</Role>
</Employee>
</Employees>
If we open the xml file in the browser will list data in treeview format.
employees ..
JSON stands for Javascript Object Notation used to represent data in key value pairs.this is also used to store and transport data.
Example : {"Name":"Syed" ,"Gender":"M"}
In the next blog post we see how to implement web api using visual studio and .net framework...
WEB API is a framework for building HTTP services that can be accessed across wide range of devices and platforms including browsers, mobile devices,IOT(Internet of things) devices, desktop devices and cross platforms.
It is perfect for building restful services.though It can be used to create services which are not restful.
Web API is very much similar to ASP.Net MVC pattern as it contains MVC like features model, controllers, action results, routing and filters .
Web API as the name suggests, is an API over the web which can be accessed using HTTP protocol.
ASP .Net Web API is an add on to the ASP.Net Framework. and web api actions(methods) are requested by HTTP verbs(GET,POST,PUT,DELETE).
What is API ?
It is perfect for building restful services.though It can be used to create services which are not restful.
Web API is very much similar to ASP.Net MVC pattern as it contains MVC like features model, controllers, action results, routing and filters .
Web API as the name suggests, is an API over the web which can be accessed using HTTP protocol.
ASP .Net Web API is an add on to the ASP.Net Framework. and web api actions(methods) are requested by HTTP verbs(GET,POST,PUT,DELETE).
What is API ?
API : API stands for Application Program Interface, which has tools and protocols to develop software applications.
What is Restful ?
REpresentational State Transfer (REST) is an architectural style that has a set of configurations and properties based on HTTP(Hyper Text Transfer Protocol)
Rest Constraints :
- Client Server
- Stateless
- Cacheable
- Uniform Interface
The principles of REST are
Client-Server - Client sends the request and sever sends the response
Uniform Interface - defines Interface between client and server. here each resource is identified by URI (Uniform Resource Identifier)
Stateless - Communication between client and server should be stateless
Cacheable - Used to avoid unnecessary call backs to the server for common data required at the client over and over again
WEB API is a concept not a technology.web api is cross platform can be used in other technologies like java. for example twitter api allows us query and read tweets from our twitter account and does not dictate any architectural style to create services.
Following are the terms and frequently used in web api programming
- Resources and URIs
- HTTP Methods
- HTTP Status Codes
- HTTP Content
- Internet Media Types
- JSON & XML
HTTP : Hyper Text Transfer Protocol is stateless protocol.
Which does not maintain any state between client and server communication and treats every request as new one.
Which does not maintain any state between client and server communication and treats every request as new one.
URI : Uniform Resource Identifier is a string of characters used to identify the resource on internet using name or location.
URI is used to identify resources, For example, In real world assume there is a person named “X” who lives in “AL SHALI BUILDING,FLOOR 6,DOOR NO 201,XXXX Country”. We can find that person by name or by address or by both.
URI can be categorized into 2 as URL and URN
URL: Uniform Resource Locator
URN: Uniform Resource Name
URI is used to identify the resource on the internet.
It can be done by both URN and URL, but using URN is not sufficient because there can be many resources with the same name. Most commonly used method is URL and it consists of two required components; The Protocol & The Domain.
It can be done by both URN and URL, but using URN is not sufficient because there can be many resources with the same name. Most commonly used method is URL and it consists of two required components; The Protocol & The Domain.
Example :
http://www.dotnetcodetree.blogspot.com/
HTTP Methods :
HTTP Methods :
Web api primarily works based on HTTP Verbs (GET/POST/PUT/DELETE)
MIME Types : A media type is a two-part identifier for file formats and format contents transmitted on the Internet.
application/javascript
application/json
application/xml
application/zip
application/pdf
multipart/form-data
.
.
.
.
.
.
.
.
HTTP Content : HTTP Request and response contains the header content which specifies the message formats and other things.
//Client request GET /webpage1.htm HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.dotnetcodetree.blogspot.com Accept-Language: en-us Accept-Encoding: gzip, deflate Connection:Keep-Alive |
//Server Response Date: Sun, 01 April 2018 12:28:53 GMT Server: Apache/2.2.14 (Win32) Last-Modified: Mon, 12 Feb 2017 19:15:56 GMT Content-Length: 88 Content-Type: text/html Connection: Closed |
JSON & XML :
XML stands for EXtensible Markup Language.Generally used to transport data over internet for communication between distributed applications.
Example :
<Employees>
<Employee>
<Name>Syed</Name>
<Role>Developer</Role>
</Employee>
<Employee>
<Name>Ashish Kumar Panda</Name>
<Role>Developer</Role>
</Employee>
</Employees>
If we open the xml file in the browser will list data in treeview format.
employees ..
- employee ..
- nameSyed
- roleDeveloper
- nameSyed
- employee ..
- nameAshish Kumar Panda
- roleDeveloper
- nameAshish Kumar Panda
JSON stands for Javascript Object Notation used to represent data in key value pairs.this is also used to store and transport data.
Example : {"Name":"Syed" ,"Gender":"M"}
In the next blog post we see how to implement web api using visual studio and .net framework...
Comments
Post a Comment