WebAPI interview questions for experienced-Part1


Part1


What is API and what is ASP.NET Web API? How it works ? Every person in IT knows what is API or they would have heard about API ? provide one API to do that operation create one API to do this operation. Provide API details like that. In this blog we will discuss some important interview questions on WebAPI.

What is API?
Application Programming Interface.

1. What is ASP.NET WebAPI ? When to use WebAPI?

  • This is a framework used to build HTTP services that reaches broad range of clients and support all browsers and mobiles and lightweight. 
  • Uses HTTP verbs. If we want to support multiple platforms with same API and uses HTTP Services then it is useful.
  •  This follows RESTFUL Representation state transfer and stateless calls. 
  • We can Provide Authentication and Authorization filters. 
  • ASP.NET Web API follows MVC architecture.

2. What is the difference between WCF and WebAPI?

WCF WEB API
Supports SOAP Supports only HTTP Protocol
More configuration required to Setup Less configuration
Supports no MVC features Supports all MVC features like Routing, Filters, Controller
It supports more data transfer lightweight and more easy for less data transfers.
Returns XML Returns JSON, XML


3. What is difference between MVC Routing and WebAPI Routing ?

Both MVC and Web API Routing are similar. Only difference is Web API uses HTTP Verbs not the URI path to select the Action.

4. What are different Status Codes in MVC?

Status Code Description
1xx Informational
2xx success
3xx Redirection
4xx Client Error
5xx Server Error

5. What is CORS?

By Using CORS we can define the domains, scheme and ports which can send request to our service.

When trying to load resource from client browser they should have permission to send request else it will throw this CORS error in client browser.

6. What is Content Negotiation?

Its a process of selecting the format of the response of Web API based on client or server preference.

By Passing Content-Type as "application/json" .

ASP.NET Web API supports XML and JSON.

7. Explain the Routing in WebAPI?

Routing Tables. In ASP.NET Web API, a controller is a class that handles HTTP requests. 

The public methods of the controller are called action methods or simply actions. 

When the Web API framework receives a request, it routes the request to an action.

8. Can we return a View in WebAPI what is base controller for API Controller?

No We cannot return a View in WebAPI controller.

9. What is REST?

REST represents Representational State Transfer. State less calls.

RESTful APIs, in most cases, return a plain text, JSON, or XML response

10. What is FromURI and FromBody?

FromURI:
The [FromUri] attribute is prefixed to the parameter to specify that the value should be read from the URI of the request.

FromBody:
the [FromBody] attribute is used to specify that the value should be read from the body of the request


Thanks for Reading.

Please go through my blogs.


Blaze meter Extension


Post a Comment

0 Comments