InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How To Handle Errors In Web Api? |
|
Answer» SEVERAL classes are AVAILABLE in Web API to handle errors. They are HTTPERROR, HttpResponseException, Exception Filters, REGISTERING Exception Filters. Several classes are available in Web API to handle errors. They are HttpError, HttpResponseException, Exception Filters, Registering Exception Filters. |
|
| 2. |
How Can We Register Exception Filter Globally? |
|
Answer» We can register exception filter GLOBALLY using following CODE: GlobalConfiguration.Configuration.Filters.Add(NEW MyTestCustomerStore.NotImplExceptionFilterAttribute()); We can register exception filter globally using following code: GlobalConfiguration.Configuration.Filters.Add(new MyTestCustomerStore.NotImplExceptionFilterAttribute()); |
|
| 3. |
How Can We Register Exception Filter From Controller? |
|
Answer» We can register exception filter from CONTROLLER USING following code: [NotImp ExceptionFilter] PUBLIC class TEST CustomerController : Controller { // WRITE the code } We can register exception filter from controller using following code: [NotImp ExceptionFilter] public class Test CustomerController : Controller { // write the code } |
|
| 4. |
How Can We Register Exception Filter From Action? |
|
Answer» We can register exception filter from ACTION USING following code [NotImp ExceptionFilter] public Test CUSTOMER Get My Test Customer(in custid) { //WRITE the code } We can register exception filter from action using following code [NotImp ExceptionFilter] public Test Customer Get My Test Customer(in custid) { //write the code } |
|
| 5. |
How Can We Register Exception Filters? |
|
Answer» Three options are available to register EXCEPTION Filters which are From ACTION, From CONTROLLER and Global REGISTRATION. Three options are available to register Exception Filters which are From Action, From Controller and Global registration. |
|
| 6. |
What Are Exception Filters? |
|
Answer» Exception filters will be executed when some of the exceptions are UNHANDLED and thrown from a CONTROLLER METHOD. The reason for the exception may be anything. Exception filters will implement "Exception FILTER" interface. Exception filters will be executed when some of the exceptions are unhandled and thrown from a controller method. The reason for the exception may be anything. Exception filters will implement "Exception Filter" interface. |
|
| 7. |
What Is Testapi? |
|
Answer» TestApi is a LIBRARY of utility and test APIs through which testers and DEVELOPERS create TESTING tools and automated TESTS for .NET and Win32 application USING data-structure and algorithms. TestApi is a library of utility and test APIs through which testers and developers create testing tools and automated tests for .NET and Win32 application using data-structure and algorithms. |
|
| 8. |
Differentiate Between Wcf And Web Api? |
|
Answer» WCF - Windows Communication Foundation(WCF) has been created by Microsoft with .NET Framework 3.0. It supports SOAP BASED services. It has compatibility with HTTP, TCP, UDP, ETC. Good for developing secure and interoperable services. Used for back end purposes. WEB API - Web API open SOURCE framework. It has compatibility with HTTP only. It has a support for non-SOAP based services. It is very light weight hence good for developing services for low bandwidth devices. It supports OData. It supports most of the MVC features. Used for front end purposes. WCF - Windows Communication Foundation(WCF) has been created by Microsoft with .NET Framework 3.0. It supports SOAP based services. It has compatibility with HTTP, TCP, UDP, etc. Good for developing secure and interoperable services. Used for back end purposes. WEB API - Web API open source framework. It has compatibility with HTTP only. It has a support for non-SOAP based services. It is very light weight hence good for developing services for low bandwidth devices. It supports OData. It supports most of the MVC features. Used for front end purposes. |
|
| 9. |
What Are The Advantages Using Webapi? |
Answer»
|
|
| 10. |
Web Api Where Is The Proxy? |
|
Answer» Web API doesn't make it EASY for consumers to GENERATE a SERVICE client LIKE a SOAP WSDL does. If you're only ever going to have .NET clients it's not a big deal because they can share the contract objects you implement, but other language clients will need to manually create their client objects if you don't use SOAP. Web API doesn't make it easy for consumers to generate a service client like a SOAP WSDL does. If you're only ever going to have .NET clients it's not a big deal because they can share the contract objects you implement, but other language clients will need to manually create their client objects if you don't use SOAP. |
|
| 11. |
With Wcf Also You Can Implement Rest, So Why Webapi? |
| Answer» | |
| 12. |
What Are The Advantages Of Using Rest In Web Api? |
| Answer» | |
| 13. |
Differences Between Wcf And Web Api? |
|
Answer» WCF :
Web API:
WCF : Web API: |
|
| 14. |
What Is Web Api Routing? |
|
Answer» ROUTING is nothing but PATTERN matching LIKE in MVC. All routes will get registered in Route TABLES. Example : Routes.MapHttpRoute( Name: "SampleWebAPIRoute", routeTemplate: “API/{controller}/{id} defaults: new { id = RouteParameter.Optional} }; Routing is nothing but pattern matching like in MVC. All routes will get registered in Route Tables. Example : Routes.MapHttpRoute( Name: "SampleWebAPIRoute", routeTemplate: “api/{controller}/{id} defaults: new { id = RouteParameter.Optional} }; |
|
| 15. |
How To Restrict Access To Methods With Specific Http Verbs In Web Api? |
|
Answer» With the help of Attributes(like HTTP verbs) one can IMPLEMENT access restrictions in Web API. We can define HTTP verbs as attribute over method to restrict access. EXAMPLE : [HttpPost] PUBLIC VOID SampleMethod(SampleClass obj) { //logic } With the help of Attributes(like http verbs) one can implement access restrictions in Web API. We can define HTTP verbs as attribute over method to restrict access. Example : [HttpPost] public void SampleMethod(SampleClass obj) { //logic } |
|
| 16. |
Can Web Api Return View In Mvc? |
|
Answer» We cannot RETURN VIEW from WEB API. We cannot return view from Web API. |
|
| 17. |
Can We Do Unit Test Web Api? |
|
Answer» Web API can be unit test by USING Fiddler tool. Following is the SETTINGS to be updated in Fiddler: Compose TAB -> Enter Request Headers -> Enter the Request Body and execute. Web API can be unit test by using Fiddler tool. Following is the settings to be updated in Fiddler: Compose Tab -> Enter Request Headers -> Enter the Request Body and execute. |
|