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.

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
  • C. DELETE
  • D. PUT

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

 Correct Answer: D

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

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

WCF Vs ASP.NET Web API?

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:

WCF REST

  • 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.

ASP.NET Web API

  • 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

MVC Vs ASP.NET Web API?

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.
MVC Vs Web API

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

Please look into following piece of code:

[ActionName(“GetById”)]

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
    [MyCustomExceptionFilter] public Student Get(string id)
    {
    return StudentRepository.GetStudent(id);
    }
  • Register Exception Filter from Controller
    [MyCustomExceptionFilter] public class StudentsController : ApiController
    {
    //Controller detailed code.
    }
  • Register Exception Filter globally
    CRUDWebAPI.MyCustomExceptionFilter ctrlr = new CRUDWebAPI.MyCustomExceptionFilter(); GlobalConfiguration.Configuration.Filters(ctrlr);

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]

Top ASP.NET MVC Jobs

Developer - Web
Source: Geocaching
Details: Proficient with ASP.NET, MVC, REST, WCF, Web API and scalable service oriented architectures. About Geocaching HQ....  More
16 days ago

Seattle, WA 98103 07-January-2017

C# Software Developer (Web Services & API)
Source: Indeed
Details: C#, ASP.NET, MVC or better required, Java/Node.js a plus. If you’re looking for a rewarding career with a dynamic and fast-growth healthcare software company,...  More
10 days ago

Seattle, WA 12-January-2017

.Net Developer
Source: Indeed
Details: .Strong Experience developing MVC applications using ASP.Net MVC. .4+ years experience in software engineering....  More
30+ days ago

Redmond, WA 30-November-2016

Sr. Web Developer (.Net/SharePoint)
Source: V3Main Technologies Inc.
Details: ASP.NET , VB.NET , C#, MVC, Entity Framework, Ajax, Bootstrap, JSON, jQuery, Knockout, HTML5, CSS3, IIS, SSL, TLS, SSH, TFS, FTP, XML, XLST, Classic ASP,...  More
6 days ago

Houston, TX 16-January-2017

.NET Developer
Source: TS Solutions
Details: ASP.NET MVC (4), C#, Azure, SQL Server. TokuSaku (TS) Solutions is looking for .NET developer with numerous bolt-on skill sets to help with our list of direct...  More
3 days ago

Seattle, WA 19-January-2017

.NET Web Application Developer
Source: NIC
Details: MVC. In-depth experience with C#, ASP.NET and MVC. Leading Web Services and E-Commerce company seeking two full-time .NET Web Application Developers to...  More
10 days ago

Frankfort, KY 13-January-2017

.NET Web Developer
Source: NIC
Details: MVC. Leading Web Services and E-Commerce company seeking a full-time .NET Web Application Developer to complement our growing team in Jackson, Mississippi....  More
11 days ago

Jackson, MS 11-January-2017

.NET Web Developer
Source: Springbox
Details: Experience with (.NET) MVC, MVP, MVVM architecture design and an understanding of design patterns, in particular OO/IoC/DI....  More
13 days ago

Austin, TX 78701 10-January-2017

Sr. Web Developer & Designer
Source: Indeed
Details: Expertise in most of the following –Web API (MS ASP.Net), MVC, WCF, HTML5, CSS, JavaScript, JSON, SOAP, REST, JQuery, .Net Framework, C#, Web Services....  More
2 days ago

Austin, TX 73301 20-January-2017

Web Developer
Source: Indeed
Details: Programming experience ASP.Net MVC, JavaScript and C# required. Securitas Security Services USA, Inc....  More
2 days ago

Westlake Village, CA 20-January-2017

.NET Web Developer
Source: Blue Earth Interactive
Details: Experience with popular web application frameworks, such as Kendo/Telerik MVC. About Blue Earth:....  More
13 days ago

Saint Paul, MN 55101 09-January-2017

Web Developer/Programmer
Source: Indeed
Details: Don't miss this great opportunity to join a leader in the equipment business at Messick’s in Elizabethtown. We are looking for a *C#* *.NET Web Engineer* to  More
4 days ago

Elizabethtown, PA 18-January-2017

Windows C# .NET MVC Web Portal Developer in Ft. Lauderdale,FL
Source: Indeed
Details: Have Experience in MVC 4.0 and 5.0 and capable of working in projects with MVC. Windows C# .NET MVC Web Portal Developer - Contract....  More
5 days ago

Fort Lauderdale, FL 18-January-2017

.Net Full Stack Developer
Source: Sonsoft Inc
Details: At least 4 years of product development experience in Dot Net technologies (C#, ASP.Net, MVC, MVVM, WCF, SQL Server)....  More
5 days ago

Redmond, WA 18-January-2017

Entry Level Developer
Source: Fairfax Data Systems
Details: Must possess a strong desire to work with different programming languages like .Net (C#, VB.Net/asp.net mvc), Java/J2EE, etc., and learn new technologies like...  More
30+ days ago

New Milford, CT 06776 13-December-2016

.NET Web Developer (Denver, CO) (Long-term Contract)
Source: Chipotle Mexican Grill
Details: ASP.Net MVC and Razor; .NET Web Developer (Denver, CO) (Long-term Contract) (17000744) Description....  More
17 days ago

Denver, CO 05-January-2017

ASP.NET / C# Software Developer (Web Services & API)
Source: Indeed
Details: C#, ASP.NET, MVC or better required, Java/Node.js a plus. The Software Developer is an experienced engineer that uses C#, ASP.NET, MVC to build web services,...  More
7 days ago

Tacoma, WA 16-January-2017

Web Developer
Source: Indeed
Details: Programming experience ASP.Net MVC, JavaScript and C# required. Securitas Secuirty Services USA, Inc....  More
9 days ago

Westlake Village, CA 13-January-2017

Wellness Programs Web Developer (Consultant)
Source: Indeed
Details: Knowledge and experience developing custom applications using MVC is essential. Develop web applications using VISUAL STUDIO.NET, ASP.NET, MVC, ADO.NET, XML,...  More
9 days ago

Brooklyn, NY 11201 13-January-2017

Full Stack .NET Developer (C#/JavaScript/SQL/Web Services)
Source: CareWorks Tech
Details: This position will: Develop and support web, middleware and database applications for internal and external deployment. Develop, implement and test project...  More
10 days ago

Columbus, OH 12-January-2017

C# ASP.Net Web Developer
Source: Indeed
Details: Experience with various web technologies, such as HTML, CSS, AJAX, JQuery, JavaScript, AngularJS, Bootstrap, XML, ASP.NET, MVC, WebForms, Web Services, IIS....  More
10 days ago

Irvine, CA 12-January-2017

.Net Full Stack Developer
Source: Sonsoft Inc
Details: At least 4 years of product development experience in Dot Net technologies (C#, ASP.Net, MVC, MVVM, WCF, SQL Server)....  More
5 days ago

Bellevue, WA 18-January-2017

Front End Web Developer
Source: Indeed
Details: *Title: * Senior Web Developer *Reports to: * Digital Channel Manager *Status: * Full-time, exempt *Location: * Boston It takes talent to be the world's  More
12 days ago

Boston, MA 10-January-2017

C# .NET Web Developer - Green Bay, WI or Indianapolis, IN
Source: UnitedHealth Group
Details: Candidates must have strengths in C#, a clear understanding of ASP.NET MVC. Welcome to one of the toughest and most fulfilling ways to help....  More
26 days ago

Indianapolis, IN 46218 28-December-2016

Jr .Net Developer
Source: Indeed
Details: Familiar with Web-API and REST in the ASP.NET MVC world. Professional job experience with C# and ASP.NET MVC (not just ASP.NET web forms). Full time/Long Term*....  More
24 days ago

Redmond, WA 29-December-2016

Top 10 Web Developer Interview Questions and Answers:

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