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

Application Developer, 4 Days Remote, 1 Day in Office
Source: Indeed
Details: Designing and developing user interfaces using ASP.NET web forms and ASP.NET MVC. .NET Framework, Ajax, ASP.NET web forms, ASP.NET MVC, jQuery, nHibernate,...  More
30+ days ago

Des Moines, IA 04-November-2016

Developer, 4 Days Remote, 1 Day in Office
Source: Indeed
Details: Designing and developing user interfaces using ASP.NET web forms and ASP.NET MVC. .NET Framework, Ajax, ASP.NET web forms, ASP.NET MVC, jQuery, nHibernate,...  More
30+ days ago

Iowa City, IA 04-November-2016

.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

.NET Developer (Remote)
Source: Indeed
Details: ASP.NET MVC using C#. 3+ years of experience building web-based applications using ASP.NET MVC – C#. This is a full-time remote position....  More
6 days ago

Nashville, TN 13-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
19 hours ago

Seattle, WA 19-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
4 days ago

Tacoma, WA 16-January-2017

Senior Software Engineer (.Net)
Source: SmartDrive Systems, Inc.
Details: Expertise in C#, ASP.Net MVC, WCF, Web API, Angular JS and SQL Server. Architect, design and develop high performing web sites, mobile applications and scalable...  More
30+ days ago

San Diego, CA 18-October-2016

UX Developer
Source: Indeed
Details: Atleast 3+years of experience in development using .NET Framework technologies like C#, ASP.NET, MVC etc. • Excellent written and verbal communication skills •...  More
6 days ago

Redmond, WA 13-January-2017

Senior C# .NET Software Engineer
Source: Clark Associates
Details: Join one of Pennsylvania’s fastest growing companies today! WebstaurantStore, a division of Clark Associates, is looking for Senior C# .NET Software Engineer  More
9 days ago

Lititz, PA 17543 10-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
7 days ago

Irvine, CA 12-January-2017

Asp.net C# developer
Source: Indeed
Details: Asp.net MVC web development experience. 2-3 year C# and .net experience....  More
8 days ago

Indianapolis, IN 12-January-2017

Developer - Web
Source: Geocaching
Details: Proficient with ASP.NET, MVC, REST, WCF, Web API and scalable service oriented architectures. About Geocaching HQ....  More
13 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
7 days ago

Seattle, WA 12-January-2017

Sr. ASP.NET Developer
Source: Indeed
Details: *ABSOLUTELY NO 3RD PARTIES FOR THIS POSITION* Participate and collaborate in design sessions ·Code / refactor one or multiple front-end web applications   More
14 days ago

Dallas, TX 75251 05-January-2017

ASP.NET MVC Web Developer
Source: Indeed
Details: 3+ years of C#, ASP.Net MVC, Entity Framework, HTML, JavaScript, JQuery, AJAX. We are in the process of switching applications from ASP.NET web forms into MVC 5...  More
15 days ago

Tigard, OR 04-January-2017

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
21 days ago

Redmond, WA 29-December-2016

Technical Lead
Source: Morgan Stanley
Details: Must be experienced in AngularJS, client-side MVC, HTML5, CSS3, JavaScript,. Must have hands-on recent expertise in C#, ASP.NET, MVC, Web API, Rest Service....  More
30+ days ago

New York, NY 10032 19-December-2016

.NET Developer
Source: Indeed
Details: Web development using ASP.NET MVC. CANDIDATE MUST BE AVAILABLE FOR IN-PERSON INTERVIEW\*\*\*\*\*....  More
1 hour ago

Minneapolis, MN 20-January-2017

Developer Sr.
Source: Adroit Partners, LLC
Details: Use technologies, such as C#, ASP.NET, MVC, SQL, No-SQL (Couchbase, MongoDB), Enterprise Service Bus, to develop technical solutions to complex problems that...  More
6 hours ago

Houston, TX 20-January-2017

Software Developer
Source: Cortland Capital Market Services
Details: ASP.NET/MVC, HTML, Ajax, JQuery, JSON, JavaScript, XML/XSLT, CSS, NET 3.5/4.0/4.5 . A unique opportunity for a skilled and career-minded software engineer with...  More
8 hours ago

Brea, CA 20-January-2017

C#.Net Application Developer(Local: F2F)
Source: Indeed
Details: Web development using ASP.NET MVC. C#.Net Applications Developer*....  More
15 hours ago

Eden Prairie, MN 20-January-2017

.NET Developer
Source: Indeed
Details: C# .NET, ASP.NET, MVC, HTML 5, JQUERY, ANGULAR, JSON, RESTFUL WEB SERVICES, ENTITY FRAMEWORK, LINQ, RESPONSIVE WEB DESIGN, MS SQL and MOBILE....  More
16 hours ago

Rockville, MD 19-January-2017

C#.Net Developer
Source: Indeed
Details: Experience building web based applications with ASP.NET, MVC, Web Forms, HTML, CSS, JavaScript, jQuery and other client-side scripting technologies....  More
17 hours ago

Winter Springs, FL 19-January-2017

Sr. Full Stack C#/.NET Developer (10+ Years experience)
Source: Indeed
Details: MVC:. Expertise in most of the following - REACT.JS, Web API (MS ASP.Net), MVC, WCF, HTML5, CSS, JavaScript, JSON, SOAP, REST, JQuery, .Net Framework, C#, Web...  More
1 day ago

Austin, TX 18-January-2017

UI developer w/ .NET background
Source: Avani Tech Solutions
Details: MVC. ASP MVC/Web API. 5 years developing applications using ASP.NET MVC. UI developer w/ .NET background....  More
1 day ago

Houston, TX 18-January-2017

Top 10 Web Developer Interview Questions and Answers:

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