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

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


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]


Senior Software Quality Assurance Engineer
Source: OneStream Software
Details: C#, Visual Basic, SQL Server, Web Services, WCF, WPF, Silverlight, XAML, XML, ASP.NET, MVC, HTML5, JavaScript, and CSS....  More
2 days ago

Stratford, CT 23-March-2017

Sr/Lead Software Engineer – C#/.Net/SQL Server – Web Services
Source: Indeed
Details: 5+ years’ experience in server technologies such as .Net, ASP.Net, ASP.Net MVC, C#, Node.js, ASP 2.0., LDAP, Active Directory.*....  More
4 days ago

Boston, MA 20-March-2017

Senior Dot Net Developer
Source: Indeed
Details: Involved in SDLC process using the ASP.NET MVC architecture. \*\*We are not looking for students enrolled/just completed education in USA....  More
10 days ago

Redmond, WA 15-March-2017

Full Stack Web Developer (ASP.NET MVC, C#)
Source: Indeed
Details: *Title: Full Stack Web Developer* *Location: Redmond, WA* *Duration: 6 months (will extend)* *Description: * Full stack front end web developer with...  More
15 days ago

Redmond, WA 10-March-2017

Junior .NET Developer
Source: NIC
Details: MVC. In-depth experience with C#, ASP.NET and MVC. Junior .Net Developer Position....  More
1 day ago

Baton Rouge, LA 23-March-2017

SQL Server DBA/Developer
Source: Indeed
Details: Ability to code in C#.NET/VB.NET and Exposure to ASP.NET, MVC, IIS, SharePoint. Long-Term/Full-time....  More
8 days ago

Latham, NY 16-March-2017

Developer - Web - Jr
Source: Kaiser Permanente
Details: C#, Angular JS, Bootstrap, MVC, Web API, Entity Framework. This is highly responsible work maintaining and maturing web presence, both Internet and...  More
4 days ago

Pasadena, CA 20-March-2017

.Net Web Developer/Software Engineer
Source: Proctor Financial, INC.
Details: Strong ability to work in Asp.Net, with ability to work in both MVC and WebForms. Our Developers work alongside with Quality Assurance, Business Analysts and...  More
1 hour ago

Troy, MI 25-March-2017

JR .Net Developer (GC/USC/EAD)
Source: Indeed
Details: *Position Description: * * This is highly responsible work maintaining and maturing web presence, both Internet and Intranet. Will be responsible for creation  More
11 hours ago

Pasadena, CA 24-March-2017

.NET Developer
Source: Indeed
Details: _ ASP.NET, MVC, WebAPI, jQuery, AngularJS. The role is responsible for collaborating with team members to design, code and maintain client-facing web...  More
13 hours ago

Addison, TX 24-March-2017

.NET backbone.js/Marionette.js Developer in Cleveland, OH
Source: Indeed
Details: Position: .NET backbone.js/Marionette.js Developer Location: Cleveland, OH Duration: 6-12 Months Client : Hexaware Technologies *Job Description: * *  More
16 hours ago

Cleveland, OH 24-March-2017

Sr. .Net Developer
Source: Indeed
Details: HTTP, AJAX, HTML5, ASP.NET MVC, JavaScript/jQuery and CSS3. Do you want to use your .Net and Software Development skills to indirectly help conquer cancer and...  More
17 hours ago

Alexandria, VA 24-March-2017

Full Stack .Net Developer (USC OR GC) Local only.
Source: Indeed
Details: 4+ years of experience with ASP.Net MVC. Bachelor’s degree preferably in Comp Sci or a related engineering degree....  More
17 hours ago

Houston, TX 24-March-2017

.Net Developer
Source: Indeed
Details: Experience with C#, .NET, Entity, MVC, Web API, HTML, CSS, JavaScript/jQuery, SQL. 2+ years of experience with C# (especially ASP.NET MVC, Web API, and Entity)....  More
20 hours ago

Louisville, KY 24-March-2017

Certified Microsoft .NET Web Developer
Source: Indeed
Details: The project includes .NET MVC web applications with heavy use of JavaScript, jQuery and Kendo UI components....  More
21 hours ago

Madison, WI 24-March-2017

Net Developer
Source: Indeed
Details: Advanced knowledge in building and deploying .NET based web applications using ASP.NET, ASP.NET MVC, WCF, and WebAPI. Hi,....  More
21 hours ago

Charlotte, NC 24-March-2017

.NET Developer
Source: Indeed
Details: 5 or more years building Web application using ASP.NET MVC. My client, an internationally renowned, full-service media agency located Downtown Chicago, is...  More
30+ days ago

Chicago, IL 07-February-2017

Certified .Net Developer
Source: Indeed
Details: The project includes .NET MVC web applications with heavy use of JavaScript, jQuery and Kendo UI components....  More
1 day ago

Madison, WI 23-March-2017

.Net Developer
Source: Resort Hospitality Solutions
Details: Create and maintain web applications based on a Microsoft web stack including C#, jQuery, Azure, ASP.Net MVC and ASP.Net Web Forms....  More
1 day ago

Asheville, NC 23-March-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
1 day ago

Chicago, IL 60606 23-March-2017

.Net Developer
Source: Resort Hospitality Solutions
Details: Create and maintain web applications based on a Microsoft web stack including C#, jQuery, Azure, ASP.Net MVC and ASP.Net Web Forms....  More
1 day ago

Duluth, GA 23-March-2017

Certified Microsoft .NET web Developer II (Job ID: WISCJP00011321)
Source: Indeed
Details: Project Duties include requirements analysis, design, front-end web application development, testing, code reviews, implementation and mentoring a team in the...  More
1 day ago

Madison, WI 23-March-2017

Full stack ASP.NET Developer
Source: Indeed
Details: MVC:. Proficiency in ASP.NET MVC 5 and C#. Our client has immediate full-time position available for skilled Dull Stack ASP.NET MVC 5/C# Web Application...  More
2 days ago

Somerset, NJ 22-March-2017

.NET Developer
Source: Procentrix
Details: .NET, C#, C++, ASP.NET, Ajax, jQuery, MVC, , WCF, Sybase SQL Anywhere/SQL Server programming. Developing custom services, components, or modules using ASP.NET...  More
2 days ago

Washington, DC 22-March-2017

Sr .Net Full stack Developer
Source: Indeed
Details: Involved in SDLC process using the ASP.NET MVC architecture. Are you passionate self-driven job seeker who can a lead in making world class software at a full...  More
23 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