ASP.NET WebAPI Interview Questions and Answers
1. What is ASP.NET Web API?
ASP.NET Web API is a framework provided by Microsoft with which is used to build HTTP services that can reach a variety of clients, including browsers, mobile, IoT devices, etc. ASP.NET Web API provides an ideal platform for building RESTful applications on the .NET Framework.
2.What is the difference between ASP.NET Web API and WCF?
WebAPI:
Limited to http services.
Media type formatters are available
Content negotiation
Opensource and ships out with .Net framework
Http Verbs are mapped to the controller methods
WCF:
Follows SOA architecture,
Multiple protocols like HTTP, TCP, Named Pipes and MSMQ etc are supported.
Uses SOAP protocol to transfer the message.
A lot of configuration required to configure the endpoint(Address, Binding, Contract and Behaviors)
Not opensource
Based on attribute based programming model
3.When to prefer ASP.NET Web API over WCF?
Choose ASP.NET Web API is you want only HTTP based services only as Web API is a lightweight architecture and is good for the devices which have limited bandwidth. We can also create the REST services with the WCF, but that requires lots of configuration. In case, if you want a service that should support multiple transport protocol like HTTP, UDP, TCP, etc. then WCF will be a better option.
- 4.What is the difference between ASP.NET MVC application and ASP.NET Web API application?
ASP.NET MVC is used to create a web application which returns both data as well as View whereas Web API is used to create HTTP based Services which only returns data not view. In an ASP.NET MVC application, requests are mapped to Action Methods whereas in the ASP.NET Web API request is mapped to Action based on the Action Verbs.
5.What are the RESTful Services?
REST stands for the Representational State Transfer. This term is coined by the Roy Fielding in 2000. RESTful is an Architectural style for creating loosely couple applications over the HTTP. In order to make API to be RESTful, it has to adhere the around 6 constraints that are mentioned below. The service implementation which follows the REST principle are said to be RESTful services. Each resource is identified by unique URI. Communication is stateless and that should be http protocol only.
Client and Server Separation: Server and Clients are clearly isolated in the RESTful services.
Stateless: REST Architecture is based on the HTTP Protocol and the server response can be cached by the clients, but no client context would be stored on the server.
Uniform Interface: Allows a limited set of operation defined using the HTTP Verbs. For eg: GET, PUT, POST, Delete etc.
Cacheable: RESTful architecture allows the response to be cached or not. Caching improves performance and scalability.
Code-On-Demand
Layered System

0 Comments
If you have any doubts then let me know