Top 10 ASP.NET Web API Interview Questions

By | May 5, 2014
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInDigg thisPin on Pinterest

In this ASP.NET Interview Questions Series, so far we have covered questions related to the core of ASP.NET technology. In this part-6 of ASP.NET Web API Tutorial series, we will cover top 10 ASP.NET Web API interview questions related to ASP.NET Web API framework. What we have covered so far can be summarized as follows:

You can follow here to create your first Single Page Application using AngualarJS and Web API, covering all CRUD (Create/Retrieve/Update/Delete) Operations. Also, you can find the list of more Advanced AngularJS Interview Questions here.

So, let’s dive deeper to understand ASP.NET Web API technology concepts through Interview Questions.

For a comprehensive list of ASP.NET MVC Interview Questions, follow here.

ASP.NET Web API Interview Questions List

More Web API Interview Questions

You are working with WebDevTutorial as a Developer and designing an ASP.NET Web API application. You need to select an HTTP verb to allow blog administrators to moderate comments posted on Web Development Tutorial blog. Which HTTP verb should you use?

  • A. GET
  • B. POST
  • D. PUT

For a complete online test and Practice Exams on Web Technologies, Click Here.

 Correct Answer: D

Foundation: HTTP and REST Concept

  • Resources and URIs
  • HTTP Methods
  • HTTP Status Codes
  • HTTP Content
  • Internet Media Types
  • REST
  • JSON & XML

HTTP (Hypertext Transfer Protocol) is an application level protocol that is used to deliver data such as html files, image files, query results, etc. on the World Wide Web. HTTP is stateless protocol means after one cycle of request and response the server forgets everything about the cycle, it considers another request from the same client as a new request from a new client.

Below is a simple Client-Server architecture of HTTP protocol.HTTP Architecture

Resource and URIs:

URI stands for Uniform Resource Identifier. URI is a string of characters used to identify a resource on the internet either by location or by name, or by both.

URI is used to identify resources, For example, In real world assume there is a person named “Muhammad Ahmad” who lives in “2807, Badar Street, Dubai”. 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

Uniform Resource Identifier

URI is used to send requests to the server. It can be done with both URN and URL, but using URN is inefficient because there can be many resources with same name. So most commonly use method is URL and it consists of two required components; The Protocol & The Domain.

Look at the following URL:

Here the red colored part is the protocol and gold color part is the domain, other parts are optional. It may contain the port/path/query strings/fragments. 

HTTP Methods:

There are multiple HTTP methods which can be used according to the user requirements. Those methods are case-sensitive and they must used in uppercase.

  • GET – The GET method is used to retrieve information from the given server using a given URI.
  • HEAD – Same as GET, but transfers the status line and header section only.
  • POST – A POST request is used to send data to the server.
  • PUT – Replaces all current resources with the uploaded content.
  • DELETE – Removes all current resources given by a URI.
  • CONNECT – Establishes a tunnel to the server identified by a given URI.
  • OPTIONS – Describes the communication options for the target resource.
  • TRACE – Performs a message loop-back test along the path to the target resource.

Among these methods GET/PUT/POST/DELETE are the most popular methods.

HTTP Status Codes:

HTTP Status Codes are the 3 digit integers which contain in server response. There is a meaning for each number. Followings are the set of status codes with its meaning:

  • 1xx: Informational-It means the request has been received and the process is continuing.
  • 2xx: Success-It means the action was successfully received, understood, and accepted.
  • 3xx: Redirection-It means further action must be taken in order to complete the request.
  • 4xx: Client Error-It means the request contains incorrect syntax or cannot be fulfilled
  • 5xx: Server Error-It means the server failed to fulfill an apparently valid request.

HTTP Content:

There are more contents in a HTTP header field. HTTP header fields are components of the header section of request or response messages in the Hypertext Transfer Protocol. It defines the operating parameters of an HTTP transaction.

For example, HTTP request to fetch webapi.htm page from the web server running on

Internet Media Types:

It is a file identification mechanism on the MIME encoding system, formerly “MIME type”, the Internet media type has become the de facto standard for identifying content on the Internet.

For example, an instance of receiving an email from a server with an attachment, the server embed the media type of the attachment in the message header. So the browser can launch appropriate helper application or plug-in.


REST (Representational State Transfer) is an architectural style for designing applications and it dictates to use HTTP for making calls for communications instead of complex mechanism like CORBA, RPC or SOAP.

There are few principles associated with REST architectural style:

  • Everything is a resource i.e. File, Images, Video, WebPage etc.
  • Every Resource is identified by a Unique Identifier.
  • Use simple and Uniform Interfaces.
  • Everything is done via representation (sending requests from client to server and receiving responses from server to client).
  • Be Stateless- Every request should be an independent request.


XML stands for eXtensible Markup Language, it is a markup language like HTML and designed to store and transport data. XML doesn’t do anything, but it store data in a specific format.

Following is a letter written from Ahmad to Hamza in XML format:

The above XML file represent the following message.

JSON (JavaScript Object Notation) also used to store and transport data. The above message can be transferred into JSON in following way:

Move on with ASP.NET Web API Interview Questions

Now, we are well familiar with HTTP and REST Concepts, let’s move on with ASP.NET Web API Interview Questions and Answers in details.ASP.NET Web API Interview Questions

What is ASP.NET Web API?

ASP.NET Web API is a framework that simplifies building HTTP services for broader range of clients (including browsers as well as mobile devices) on top of .NET Framework. Using ASP.NET Web API we can create non-SOAP based services like plain XML or JSON strings etc. with many other advantages including:

  • Create resource-oriented services using the full features of HTTP.
  • Exposing services to a variety of clients easily like browsers or mobile devices etc.

ASP.NET Web API Interview QuestionsBack to top

What are the advantages of using ASP.NET Web API?

Using ASP.NET Web API has a number of advantages, but core of the advantages are:

  • It works the HTTP way using standard HTTP verbs like GET, POST, PUT, DELETE etc for all CRUD operations.
  • Complete support for routing.
  • Response generated in JSON or XML format using MediaTypeFormatter.
  • It has the ability to be hosted in IIS as well as self-host outside of IIS.
  • Supports Model binding and Validation.
  • Support for OData.
  • and more….
For implementation on performing all CRUD operations using ASP.NET Web API, click here.70-486 Exam Preparation

Back to top

What new features are introduced in ASP.NET Web API 2.0?

More new features introduced in ASP.NET Web API framework v2.0 are as follows:

  • Attribute Routing
  • External Authentication
  • CORS (Cross-Origin Resource Sharing)
  • OWIN (Open Web Interface for .NET) Self Hosting
  • IHttpActionResult
  • Web API OData

You can follow a good Web API new feature details on Top 5 New Features in ASP.NET Web API 2 here.
Back to top

What is Attribute Routing in ASP.NET Web API 2.0?

ASP.NET Web API v2 now support “Attribute Routing” along with convention-based approach. In convention-based routes, the route templates are already defined as follows:

So, any incoming request is matched against already defined routeTemplate and further routed to matched controller action. But it’s really hard to support certain URI patterns using conventional routing approach like nested routes on same controller. For example, authors have books or customers have orders, students have courses etc.

Such patterns can be defined using attribute routing i.e. adding an attribute to controller action as follows:

Back to top


Actually, Windows Communication Foundation is designed to exchange standard SOAP-based messages using variety of transport protocols like HTTP, TCP, NamedPipes or MSMQ etc. On the other hand, ASP.NET API is a framework for building non-SOAP based services over HTTP only. WCF Vs WebAPIBack to top

WCF RESTful Service Vs ASP.NET Web API?

Although both WCF REST and ASP.NET Web API follows the REST architecture but these have follow differences:


  • Microsoft introduced “WebHttpBinding” to be used for creating WCF RESTful Services.
  • HTTP Methods are mapped to attributes, for example, “WebGet” for GET method and “WebInvoke” for POST.


  • As compared with WCF REST, Web API supports full features of HTTP.
  • Its possible to host Web API in IIS as well as in an application.

WCFREST Vs WebAPIBack to top

Is it true that ASP.NET Web API has replaced WCF?

It’s a misconception that ASP.NET Web API has replaced WCF. It’s another way of building non-SOAP based services, for example, plain XML or JSON string etc.
Yes, it has some added advantages like utilizing full features of HTTP and reaching more clients such as mobile devices etc.
But WCF is still a good choice for following scenarios:
  • If we intended to use transport other than HTTP e.g. TCP, UDP or Named Pipes.
  • Messag Queuing scenario using MSMQ.
  • One-way communication or Duplex communication
A good understanding for WCF(Windows Communication Foundation), please follow WCF Tutorial.

Back to top


As in previous ASP.NET Web API Interview Questions, we discussed that purpose of Web API framework is to generate HTTP services that reaches more clients by generating data in raw format, for example, plain XML or JSON string. So, ASP.NET Web API creates simple HTTP services that renders raw data. On the other hand, ASP.NET MVC framework is used to develop web applications that generates Views as well as data. ASP.NET MVC facilitates in rendering HTML easy.

For ASP.NET MVC Interview Questions, follow the link.
Back to top

Please look into following piece of code:


public ActionResult GetEmployeeById()
//Code logic here.

return View();
What’s true about the above code.

  • A. “GetEmployeeById” action method with be identified and called by name “GetEmployeeById”.
  • B. “GetEmployeeById” action method with be identified and called by name “GetById”.
  • C. Above code will generate an error because of wrong return type.
  • D. Action method can’t be called because of duplicate action method names.

For a complete online test and Practice Exams on Web Technologies, Click Here.

 Correct Answer: B

How to return View from ASP.NET Web API method?

(A tricky Interview Question) No, we can’t return view from ASP.NET Web API Method. As we discussed in earlier interview question about difference between ASP.NET MVC and Web API that ASP.NET Web API creates HTTP services that renders raw data. Although, it’s quite possible in ASP.NET MVC application.
Back to top

How to restrict access to Web API method to specific HTTP Verb?

Attribute programming plays it’s role here. We can easily restrict access to an ASP.NET Web API method to be called using a specific HTTP method. For example, we may required in a scenario to restrict access to a Web API method through HTTP POST only as follows:
Restrict Access in Web API

Back to top

Can we use Web API with ASP.NET Web Form?

Yes, ASP.NET Web API is bundled with ASP.NET MVC framework but still it can be used with ASP.NET Web Form. It can be done in three simple steps as follows:

  1. Create a Web API Controller.
  2. Add a routing table to Application_Start method of Global.asax.
  3. Make a jQuery AJAX Call to Web API method and get data.
jQuery call to Web API for all CRUD (Create, Retrieve, Update, Delete) operations can be found here.

Back to top

How we can provide an alias name for ASP.NET Web API action?

We can provide an alias name for ASP.NET Web API action same as in case of ASP.NET MVC by using “ActionName” attribute as follows:

Web API Action Alias

ASP.NET Web API 2 Hands On
Building RESTful Web Service using ASP.NET Web API2 taking from beginner level and learn how to use the new features of Web API2 i.e. Attribute Routing etc. More Details

Back to top

What are Exception Filters? What are different ways to register exception filters?

Exception Filter is basically a class that implements IExceptionFilter interface. While working with ASP.NET Web API, there can be scenarios where the code can generate unhandled exceptions. And for those unhandled exceptions, client will be receiving same generic error i.e. “Internal Server Error”. In order to tackle such unhandled exceptions, Exception Filters can be used.

You can follow here for a detailed article on Exception Handling in ASP.NET Web API with following implementation:

  • What are Exception Filters in Web API?
  • How we can create a Custom Exception Filter?
  • How we can register Custom Exception Filter at different levels?

We can register exception filters for ASP.NET Web API in following different levels:

  • Register Exception Filter from action
  • Register Exception Filter from Controller
  • Register Exception Filter globally

Back to top

How we can guarantee that our Web API returns JSON data only?

In order to ensure that our ASP.NET Web API serialize the returning object to JSON format and returns JSON data only, we have to add following piece of code in WebApiConfig.cs class of our MVC Web API Project:Web API JSON Tutorial

Back to top

In this ASP.NET Web API Tutorial, we covered most important Interview Questions on ASP.NET Web API framework. Hopefully, it will be helpful for Web API developer Interview but along with these questions, do the practical implementation as much as you can. In Practical guide to ASP.NET Web API, you can find a good step by step approach for understanding and implementing ASP.NET Web API services.

Previous <<< ASP.NET Interview Questions – Part -5

Other Related Articles:

ASP.NET MVC & Web API Jobs [Updated Daily]


Web Developer
Source: Indeed
Details: ASP.NET MVC, Entity Framework:. 3-5+ years of experience designing complex web applications in ASP.NET MVC, Entity Framework....  More
9 days ago

Redmond, WA 20-April-2017

Software Developer (Jr/Mid)
Source: Blue Canopy
Details: ASP.NET MVC and Web Forms, SQL Server, Visual Studio, TFS, C#, HTML, CSS, JavaScript. Blue Canopy Group, LLC is seeking a Software Developer (Jr/Mid) for our...  More
2 days ago

Fort Meade, MD 27-April-2017

Jr. Front End Angular 2 Developer
Source: Phenomenex
Details: Experience with ASP.NET MVC, REST Services. The right candidate will have a passion for software development, good communication skills, and the ability to...  More
4 days ago

Torrance, CA 90501 25-April-2017

Web Developer
Source: BoatUS
Details: ASP. BoatU.S., a part of GEICO and the Berkshire Hathaway family of companies, is looking for a Web Developer at our Headquarters in Alexandria, VA....  More
2 days ago

Alexandria, VA 28-April-2017

.NET Full Stack Developer
Source: Indeed
Details: .NET / ASP.NET / MVC development environment:. Candidates should have full stack experience for ASP.NET MVC Web Development in particular....  More
4 days ago

Cerritos, CA 90703 25-April-2017

Jr. Software Developer
Source: Ellie Mae
Details: Familiarity with ASP.NET MVC and/or .NET Web API a plus. Ellie Mae is a provider of enterprise on-demand solutions, including an online network, software and...  More
10 days ago

Pleasanton, CA 94588 19-April-2017

Web Developer
Source: Indeed
Details: Experience with bootstrap, ASP.NET MVC a plus. Expertise in front-end web development • Proficiency with HTML, CSS, javascript, Angular.js • Experience with...  More
30+ days ago

Redmond, WA 23-March-2017

Web Developer
Source: Indeed
Details: The National Fire Protection Association’s mission is to help save lives and reduce loss with information, knowledge and passion. An international nonprofit  More
15 days ago

Quincy, MA 14-April-2017

.NET Software Developer (Jr/Mid)
Source: Blue Canopy
Details: ASP.NET MVC and Web Forms, SQL Server, Visual Studio, TFS, C#, HTML, CSS, JavaScript. Blue Canopy Group, LLC is seeking a .Net Software Developer (Jr/Mid) for...  More
21 days ago

Fort Meade, MD 08-April-2017

Full Stack .Net Developer
Source: Indeed
Details: Candidates should have full stack experience for ASP.NET MVC Web Development in particular. Cypress North Corp, a leading software engineering and digital...  More
23 days ago

Buffalo, NY 14210 06-April-2017

Software Engineer .NET, C#
Source: American College of Healthcare Executives
Details: Utilize ACHE’s evolving technology stack including Visual Studio, C#, MS SQL Server, ASP.NET, MVC, XML/XSLT, JavaScript, and jQuery....  More
4 days ago

Chicago, IL 60606 26-April-2017

Creative Full-Stack ASP.Net Developer
Source: Indeed
Details: Minimum 3-5yrs ASP.Net MVC (C#) web development experience “Full-Stack” preferred:. Understanding of C#, MVC, HTML, Javascript, CSS, Entity Framework, SQL...  More
26 days ago

Denver, CO 03-April-2017

Jr. .Net Developer - TS/SCI
Source: LongView International Technology Solutions Inc.
Details: Strong knowledge of Visual Studio 2013, Team Foundation Server, ASP.Net MVC, Angular 1.7, Bootstrap v3, WebAPI , LINQ,....  More
30+ days ago

Fort Belvoir, VA 29-March-2017

Mobile Application Developer
Source: Indeed
Details: Proficient in writing Web API (ASP.NET MVC WebAPI, EF6.0). Prior experience in Hybrid web application development using ASP.NET MVC, and client frameworks like...  More
3 days ago

Charlotte, NC 26-April-2017

Web Developer
Source: GenConnect Recruiting and Consulting
Details: Solid understanding of Microsoft ASP.Net MVC 5 and Microsoft ASP.Net Web Api 2. Are you interested in joining a company that will map out your development...  More
26 days ago

Atlanta, GA 03-April-2017

Senior ASP.NET Developer
Source: Brogden Enterprises, Inc.
Details: Experience working with ASP.NET MVC and nHibernate. Member of the programming team responsible for the design, development and enhancement of websites....  More
8 days ago

Aberdeen, MD 21-April-2017

Senior ASP.NET Developer
Source: Brogden Enterprises, Inc.
Details: Experience working with ASP.NET MVC and nHibernate. Member of the programming team responsible for the design, development and enhancement of websites....  More
8 days ago

Huntsville, AL 21-April-2017

Software Engineer C#/ASP.NET MVC/JavaScript
Source: Cormant, Inc.
Details: You will be working on full stack development including Marionette client, and a C# MVC architecture with NHibernate/RDBMS as the back-end....  More
8 days ago

San Luis Obispo, CA 21-April-2017

Web Developer
Source: Hubert
Details: Experience with any modern MVC web architecture (ASP.NET MVC, Ruby/Rails, Django/Python, etc.). Programmer, web programmer, web development, MVC web...  More
26 days ago

Harrison, OH 45030 03-April-2017

Senior ASP.NET MVC Developer
Source: Indeed
Details: 4+ years experience developing web applications using ASP.NET MVC. The successful candidate provides great interpersonal and communication skills coupled with...  More
9 days ago

Lake Orion, MI 20-April-2017

Sr. C#/ASP.NET Developer
Source: Logic20/20
Details: *Strong C#, .NET framework (ASP.NET MVC, Entity Framework), jQuery, HTML 5 development Qualifications. Logic20/20 is a Seattle based Management & Technology...  More
12 days ago

Seattle, WA 98115 18-April-2017

SQL Report Developer (N. Pittsburgh)
Source: Indeed
Details: Experience with ASP.NET MVC is a plus. Please no contractors, local candidates only....  More
1 day ago

Pittsburgh, PA 29-April-2017

Application Developer
Source: Indeed
Details: MVC:. Microsoft.Net Framework 4.0 and higher, C#, ASP.Net, MVC, WebAPI, Javascript, AJAX, JSON. Franklin based technology consulting firm is recruiting a .Net...  More
12 days ago

Franklin, TN 37067 17-April-2017

Full Stack .NET Developer
Source: Forte Group
Details: Experience with ASP.NET, MVC and .NET Framework; One of the largest technology providers is currently looking for a Full Stack .NET Developer to join their team...  More
30+ days ago

Chicago, IL 60606 23-March-2017

Full Stack .Net Developer with MS dynamics
Source: Indeed
Details: (SDE with C#/ASP.Net/MVC, SQL Server, etc. - Microsoft stack) ~ Experience working with PCI compliant systems - examples: great plains or MS Dynamics  More
30+ days ago

Seattle, WA 02-March-2017

Top 10 Web Developer Interview Questions and Answers:

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInDigg thisPin on Pinterest