0% found this document useful (0 votes)
178 views25 pages

Top ASP.NET Web API Interview Questions

ASP.NET Web API is a framework provided by the Microsoft with which we can easily build HTTP services that can reach a broad of clients, including browsers, mobile, IoT devices, etc. ASP.NET Web API provides an ideal platform for building RESTful applications on the .NET Framework.

Uploaded by

AJIT SAMAL
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
178 views25 pages

Top ASP.NET Web API Interview Questions

ASP.NET Web API is a framework provided by the Microsoft with which we can easily build HTTP services that can reach a broad of clients, including browsers, mobile, IoT devices, etc. ASP.NET Web API provides an ideal platform for building RESTful applications on the .NET Framework.

Uploaded by

AJIT SAMAL
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
  • Introduction
  • Q-1 What is ASP.NET Web API?
  • Q-2 What is the difference between ASP.NET Web API and WCF?
  • Q-3 When to prefer ASP.NET Web API over WCF?
  • Q-4 Which .NET Framework supports ASP.NET Web API?
  • Q-5 Can we consume ASP.NET Web API in applications created using other than .NET?
  • Q-6 What is the difference between ASP.NET MVC application and ASP.NET Web API application?
  • Q-7 What are the RESTful Services?
  • Q-8 What are the new features introduced in ASP.NET Web API 2.0?
  • Q-9 Can we return View from Web API?
  • Q-10 Does ASP.NET Web API replace the WCF?
  • Q-11 What is Request Verbs or HTTP Verbs?
  • Q-12 What are HTTP Status Codes?
  • Q-13 What is Parameter Binding in ASP.NET Web API?
  • Q-14 What is Content Negotiation in Web API?
  • Q-15 What is Media-Type Formatter in ASP.NET Web API?
  • Q-16 What is the use of Authorize Attribute?
  • Q-17 What is Basic HTTP Authentication?
  • Q-18 How Web API Routes HTTP request to the Controller ASP.NET MVC?
  • Q-19 In How many ways we can do Web API Versioning?
  • Q-20 What is Exception handling?
  • Summary

Top 20 ASP.

NET Web API Interview


Questions
[Link] Web API is a framework provided by the
Microsoft with which we can easily build HTTP
services that can reach a broad of clients,
including browsers, mobile, IoT devices, etc.
Introduction [Link] Web API provides an ideal platform for
building RESTful applications on the .NET
Framework.
[Link] Web API is a framework provided by the
Q- 1 What is Microsoft with which we can easily build HTTP
services that can reach a broad of clients,
[Link] Web including browsers, mobile, IoT devices, etc.
[Link] Web API provides an ideal platform for
API? building RESTful applications on the .NET
Framework.

Web API is a Framework to build HTTP Services that
can reach a board of clients, including browsers,
mobile, IoT Devices, etc. and provided an ideal
Q:- 2 What is platform for building RESTful applications. It is limited
to HTTP based services. [Link] framework ships out
the difference with the .NET framework and is Open Source. WCF i.e.
between Windows Communication Foundation is a framework
used for building Service Oriented applications (SOA)
[Link] Web and supports multiple transport protocol like HTTP,
TCP, MSMQ, etc. It supports multiple protocols like
API and WCF? HTTP, TCP, Named Pipes, MSMQ, etc. WCF ships out
with the .NET Framework. Both Web API and WCF can
be self-hosted or can be hosted on the IIS Server.
It totally depends upon the requirement. Choose
[Link] Web API is you want only HTTP based
Q:-3 When to services only as Web API is a lightweight
prefer [Link] architecture and is good for the devices which
have limited bandwidth. We can also create the
Web API over REST services with the WCF, but that requires lots
of configuration. In case, if you want a service
WCF? that should support multiple transport protocol
like HTTP, UDP, TCP, etc. then WCF will be a better
option.
Q:-4 Which .NET First Version of [Link] Web API is introduced in
.NET Framework 4. After that, all the later
Framework versions of the .NET Framework supports the
supports [Link] Web API.

[Link] Web
API?
Q-5 Can we
consume [Link]
Web API in Yes, we can consume [Link] 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 [Link] 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 [Link] which only returns data not view. In an [Link]
MVC application MVC application, requests are mapped to Action
and [Link] Web Methods whereas in the [Link] 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 [Link] Web API 2.0:
Q-8 What are the new • Attribute Routing
features introduced in • CORS (Cross-Origin Resource Sharing)
[Link] 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, [Link] Web API didn’t replace WCF
[Link] 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

4 4** Client Side Error

5 5** Server Side Error

• Table: HTTP Status Code with Description


• Some of the commonly seen HTTP Status Codes are: 200
(Request is Ok), 201 (Created), 202 (Accepted), 204 (No Content),
Continuing to Q- 12 301 (Moved Permanently), 400 (Bad Request), 401
(Unauthorized), 403 (Forbidden), 404 (Not Found), 500 (Internal
Server Error), 502 (Bad Gateway), 503 (Service Unavailable) etc.
When Web API calls a method on a
controller, it must set the values for the
parameters, this particular process is
known as Parameter Binding. By Default,
Web API uses the below rules in order to
Q-13 What is bind the parameter:
Parameter Binding in • FromUri: If the parameter is of “Simple”
type, then Web API tries to get the value
[Link] Web API? from the URI. Simple Type [Link]
Primitive type like int, double, etc.,
DateTime, TimeSpan, GUID, string, any
type which can be converted from the
string type.
• FromBody: If the parameter is of
“Complex” type, then Web API will try to
bind the values from the message body.
Content Negotiation is the process of selecting
the best representation for a given response
when there are multiple representations
available. Two main headers which are
Q-14 What is responsible for the Content Negotiation are:
Content Negotiation • Content-Type
in Web API? • Accept
The content-type header tells the server about
the data, the server is going to receive from
the client whereas another way to use Accept-
Header, which tells the format of data
requested by the Client from a server. In the
below example, we requested the data from
the server in JSON format.
Media-Type formatter is an abstract class
from which JsonMediaTypeFormatter
Q-15 What is Media- (handle JSON format) and
XmlMediaTypeFormatter (handle XML
Type Formatter in format) class derived from. Media-Type
[Link] Web API? formatter are classes responsible for
serializing the response data in the
format that the client asked for.

Q-16 What is the Web API provided a built-in authorization
filter, i.e. Authorize Attribute. This filter
use of Authorize checks whether the user is authenticated
Attribute? or not. If not, the user will see 401
Unauthorized HTTP Status Code.
Basic HTTP Authentication is a
mechanism, where the user is
Q-17 What is Basic authenticated through the service in
HTTP which the client pass username and
password in the HTTP Authorization
Authentication? request headers. The credentials are
formatted as the string
“username:password”, based encoded.
Q-18 How Web API In [Link] Web API, HTTP request maps
Routes HTTP request to the controller. In order to determine
to the Controller which action is to invoke, the Web API
framework uses a routing table.
[Link] MVC?
We can do Web API Versioning in the
Q-19 In How many following ways:
ways we can do Web • URI
API Versioning? • Query String Parameter
• Custom Header Parameter
• Accept Header Parameter
Exception handling is a technique to
Q-20 What is handle runtime error in the application
code. In multiple ways we can handle
Exception the error in [Link] Web API, some of
handling? them are listed below:
• HttpResponseException
• HttpError
• Exception Filters etc.
I hope these questions and answers
will help you to crack your Web API
Interview. These interview Questions
have been taken from our new
released eBook [Link] Web API
Interview Questions.
Summary This eBook has been written to
make you confident in Web API with a
solid foundation. It's would be equally
helpful in building REST API using
[Link] Web API and integrating it
with your real projects.

Top 20 ASP.NET Web API Interview 
Questions
Introduction
ASP.NET Web API is a framework provided by the
Microsoft with which we can easily build HTTP
services that can r
Q- 1 What is 
ASP.NET Web 
API?
ASP.NET Web API  (https://www.dotnettricks.com/training/masters-program/mvc-webapi)is a frame
Q:- 2 What is 
the difference 
between 
ASP.NET Web 
API and WCF? (https://www.dotnettricks.com/learn/webapi/difference-betwe
Q:-3 When to 
prefer ASP.NET 
Web API over 
WCF?
It totally depends upon the requirement. Choose 
ASP.NET Web API is you want
Q:-4 Which .NET 
Framework 
supports 
ASP.NET Web 
API?
First Version of ASP.NET Web API is introduced in 
.NET Framework 4.
Q-5 Can we 
consume ASP.NET 
Web API in 
applications 
created using 
other than .NET?
Yes, we can consume ASP.NET Web API in
Q-6 What is the 
difference 
between ASP.NET 
MVC application 
and ASP.NET Web  (https://www.dotnettricks.com/learn/webapi/di
Q:-7 What are the 
RESTful Services?
REST stands for the Representational State Transfer. This term is 
coined by the Roy Fie
Q-8 What are the new 
features introduced in 
ASP.NET Web API 2.0?
The following features have been 
introduced in ASP.NET We

You might also like