WebAPI is a framework which helps you to build/develop HTTP services.
Why is Web API required? Is it possible to use RESTful services using WCF?
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. 1. Web API increases TDD (Test Data Driven) approach in the development of RESTful services. 2. If we want to develop RESTful services in WCF, you surely need a lot of config settings, URI templates, contracts & endpoints for developing RESTful services using web API.
What are the advantages of Web API?
Advantages of Web API are: 1. OData 2. Filters 3. Content Negotiation 4.Self-Hosting 5. Routing6. Model Bindings
What are main return types supported in Web API?
A Web API controller action can return following values: 1. Void – It will return empty content. 2. HttpResponseMessage – It will convert the response to an HTTP message. 3. IHttpActionResult – internally calls ExecuteAsync to create an HttpResponseMessage. 4. Other types – You can write the serialized return value into the response body.
Web API supports which protocol?
Web App supports HTTP protocol.
Which .NET framework supports Web API?
NET 4.0 and above version supports web API.
By default, Web API sends HTTP response with which of the following status code for all uncaught exception?
500 – Internal Server Error
What is the biggest disadvantage of “Other Return Types” in Web API?
The biggest disadvantage of this approach is that you cannot directly return an error code like 404 error.
Routing is pattern matching like in MVC.All routes are registered in Route Tables.
How can we use Web API with ASP.NET Web Form?
Web API can be used with ASP.NET Web Form It can be performed in three simple steps: 1. Create a Web API Controller. 2. Add a routing table to Application_Start method of Global.asax 3. Then you need to make a jQuery AJAX Call to Web API method and get data.
How to you can limit Access to Web API to Specific HTTP Verb?
Attribute programming plays a important role. It is easy to restrict access to an ASP.NET Web API method to be called using a particular HTTP method.
Can you use Web API with ASP.NET Web Form?
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.
What is the meaning of TestApi?
TestApi is a utility library of APIs. Using this library tester developer can create testing tools and automated tests for a .NET application using data-structure and algorithms.
Explain exception filters?
It will be executed when exceptions are unhandled and thrown from a controller method. The reason for the exception can be anything. Exception filters will implement “IExceptionFilter” interface.
How you can return View from ASP.NET Web API method?
No, we can’t return a view from ASP.NET Web API Method. Web API creates HTTP services that render raw data. However, it’s also possible in ASP.NET MVC application.
How to register exception filter globally?
It is possible to register exception filter globally using following code- GlobalConfiguration.Configuration.Filters.Add(new MyTestCustomerStore.NotImplExceptionFilterAttribute());
Explain what is REST and RESTFUL?
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 is called RESTful services. It focuses on system resources and how the state of the resource should be transported over HTTP protocol.
How to unit test Web API?
We can perform a Unit test using Web API tools like Fiddler. Here, are some setting to be done if you are using Fiddler –Compose Tab -> Enter Request Headers -> Enter the Request Body and execute
How can we restrict access to methods with specific HTTP verbs in Web API?
Attribute programming is widely used for this functionality. Web API also allows restricting access of calling methods with the help of specific HTTP verbs. It is also possible to define HTTP verbs as attribute over method.
WebAPI can be consumed by any client which supports HTTP verbs such as GET, PUT, DELETE, POST. As WebAPI services don’t need any configuration, they are very easy to consume by any client. Infract, even portable devices like Mobile devices can easily consume WebAPI which is certainly the biggest advantages of this technology.