Top 20 ASP - NET Web API Interview Questions
Top 20 ASP - NET Web API Interview Questions
ASP.NET Web
API?
Q-5 Can we
consume ASP.NET
Web API in Yes, we can consume ASP.NET Web API in the
applications created using another language than
applications .NET but that application must have
access/supports to the HTTP protocol.
created using
other than .NET?
Q-6 What is the ASP.NET MVC is used to create a web application
difference which returns both data as well as View whereas
Web API is used to create HTTP based Services
between ASP.NET which only returns data not view. In an ASP.NET
MVC application MVC application, requests are mapped to Action
and ASP.NET Web Methods whereas in the ASP.NET Web API
request is mapped to Action based on the Action
API application? Verbs.
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:
• Client and Server Separation: Server and Clients are clearly
Q:-7 What are the isolated in the RESTful services.
• Stateless: REST Architecture is based on the HTTP Protocol and
RESTful Services? 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
The following features have been
introduced in ASP.NET Web API 2.0:
Q-8 What are the new • Attribute Routing
features introduced in • CORS (Cross-Origin Resource Sharing)
ASP.NET Web API 2.0? • OWIN (Open Web Interface for .NET)
self-hosting
• IHttpActionResult
• Web API OData etc.
Q-9 Can we return No, Web API does not return View but
View from Web they return the data. APIController is
meant for returning the data. So, if you
API? need to return a view from the controller
class, then make sure to use or inherit
the Controller class.
Q:-10 Does No, ASP.NET Web API didn’t replace WCF
ASP.NET Web API Service as it is only used for creating
RESTful Service i.e. non-SOAP based
replace the WCF? service.
In RESTful service, we can perform all types of
CRUD (Create, Read, Update, Delete) Operation.
In REST architecture, it is suggested to have a
specific Request Verb or HTTP verb on the
Q-11 What is specific type of the call made to the server.
Popular Request Verbs or HTTP Verbs are
Request Verbs or mentioned below:
• HTTP Get: Used to get or retrieve the
HTTP Verbs? resource or information only.
• HTTP Post: Used to create a new
resource on the collection of resources.
• HTTP Put: Used to update the existing
Response
• HTTP Delete: Used to Delete an existing
resource.
Q-12 What are HTTP Status Code Is 3-digit integer in
HTTP Status which the first digit of the Status-Code
Codes? defines the class of response. Response
Header of each API response contains
the HTTP Status Code. HTTP Status
Codes are grouped into five categories
based upon the first numbe
S. No. HTTP Status Code Description
1 1** Information
2 2** Success
3 3** Redirection