Top 23 WEB API Interview Questions And Answers
Q1. What is web API ?
ANS : Web API as a framework which helps you to create and develop HTTP based restful services
Q2. Why is web API required is it possible to use restful services using WCF ?
ANS : Yes we can still develop restful services with WCF however there are two main reasons that prompt users to use web api instead of restful services web api increases TDD test data driven approach in the development of restful services if we want to develop restful services in WCF you surely need a lot of config settings Paree templates contracts and endpoints for developing restful services using web api
Q3. Why select web API ?
ANS : It is used to create simple non SOAP based HTTP services it is also an easy method for creation with web API with WCF rest services it is based on HTTP and easy to define expose and consumed in a restful way it is lightweight architecture and ideal for devices that have limited bandwidth like smart phones
Q4. Is it right that ASP. NET web API has replaced WCF ?
ANS : It's a not at all true that ASP .NET web API has replaced WCF in fact it is another way of building non SOAP based services i.e plain XML or JSON string
Q5. What are the advantages of web API ?
ANS : Advantages of web API our OData filters content negotiation self hosting routing model bindings
Q6. What our main return type supported in web API ?
ANS : Web API controller action can return following values void it will return empty content HTTP response message it will convert the response to an HTTP message impaction result internally calls executi sync to create an HTTP response message other types you can write the serialized return value into the response body
Q7. Web API supports which protocol ?
ANS : Web API supports HTTP protocol
Q8. Which DOT NET framework supports web API ?
ANS : DOT Net 4.0 and above version supports web API
Q9. Web API uses which open source library for JSON serialization ?
ANS : Web API uses JSON net library for JSON serialization
Q10. By default web API sends HTTP response which status code for all uncaught exception
ANS : 500 internal server error
Q11. What is the biggest disadvantage of other return types in web API ?
ANS : The biggest disadvantage of this approach is that you cannot directly return an error code like 404 error
Q12. What is web API routing ?
ANS : The answer is routing is pattern matching like in MVC all routes are registered in route tables
Q13. What is SOAP ?
ANS : SOAP is an XML message format used in web service interactions it allows to send messages over HTTP or JMS but other transport protocols can be used it is also an XML based messaging protocol for exchanging information among computers
Q14. What is the benefit of using REST in web API ?
ANS : REST is used to make fewer data transfers between client and server which make it an ideal for using it in mobile apps web api also supports HTTP protocol therefore it reintroduces the traditional way of the HTTP verbs for communication
Q15. How can we use web API with ASP .NET web form ?
ANS : Web API can be used with ASP .NET web form it can be performed in three simple steps :-
(A). Create a web API controller
(B). Add a routing table to application underscore
(C). Start method of global dot sachs then you need to make a jquery ajax call to web api method and get data
Q16. How do you can limit access to web API to specific HTTP verb ?
ANS : Attribute programming plays an important role it is easy to restrict access to an ASP .NET web API method to be called using a particular HTTP method
Q17. Can you use web API with ASP .NET web form ?
ANS : Yes it is possible to use web API with ASP .NET web form as it is bundled with ASP .NET MVC framework however it can be used with ASP.NET web form
Q18. How we can assign alias name for ASP .NET web API action ?
ANS : As we can give alias name for web API action same as in case of asp.net MVC by using action name.
Q19. What is the meaning of test Oppie ?
ANS : As test Oppie as a utility library of AP is using this library tester developer can create testing tools and automated tests for a NET application using data structure and algorithms
Q20. Explain exception filters ?
ANS : As it will be executed when exceptions are unhandled and thrown from a controller method the reason for the exception can be anything exception filters
Q21. How you can return view from ASP .NET Web API method ?
ANS : No we can't return a view from a spinette web API method web API creates HTTP services that render raw data however it's also possible in ASP .NET MVC application
Q22. Explain what is rest and restful ?
ANS : As rest represents representational state transfer it is entirely a new aspect of writing a web app restful it is term written by applying rest architectural concepts as called restful services it focuses on system resources and how the state of the resource should be transported over HTTP protocol
Q23. How can you handle errors in web API ?
ANS : As several classes are available in web api to handle errors they are HTTP error exception filters HTTP response exception and registering exception filters.
0 comments:
Post a Comment