In this session, we will see ASP.NET Web API Interview Questions that are asked during Interviews. ASP.NET Web API is very famous nowadays.
ASP.NET Web API Interview Questions:
1-What is a Web API?
Ans- ASP.NET Web API is a framework for building HTTP Services that can be consumed by a broader range of clients like browsers and mobile devices. ASP.NET Web API can be used to create non-soap based services like XML or JSON string etc. ASP.NET Web API has many other advantages like.
- Web API is used to create Non-Soap Service with the full support of HTTP.
- The Web API can be consumed by a broader range of clients like browsers and mobile devices.
2-What are the advantages of using ASP.NET Web API?
Ans- ASP.NET Web API has a number of advantages:
- It works the HTTP way using the Standard Verb GET, POST, PUT DELETE etc.
- It has full support for routing.
- The response can be 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.
- Support model binding and validations.
- Support for OData.
The Open Data Protocol (OData) is a data access protocol for the web. OData provides a uniform way to query and manipulate data sets through CRUD operations (create, read, update, and delete).
3- What is REST?
Ans- REST stands for Representational State Transfer was first conceived by Roy Fielding. REST is an architectural pattern that uses HTTP as its underlying pattern. It is an approach to communications that can be used while developing Web Services.
4- What are the main Return types supported in Web API?
Ans- A Web API controller can return following types of values.
- void: It will return empty content(204).
- HttpResponseMessage: Convert directly to an HTTP response message.
- IHttpResponseMessage: This will internally call the ExecuteSync method to create an HTTPResponseMessage then convert to an HTTP response message.
- Other return types: You can write the serialized value into the return body.
5- 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.
6- Explain Web API Routing?
Routing in ASP.NET Web API is a pattern matching system as we have in ASP.NET MVC. These Routes will get registered in Route Tables. Here is the sample code for Routing in ASP.NET Web API:
Routes.MapHttpRoute( Name: "MyFirstWebAPIRoute", routeTemplate: “api/{controller}/{id} defaults: new { id = RouteParameter.Optional} };
6- How can we handle errors in Web API?
Ans- Here are the number of classes that can be used to handle errors in Web API.
- HTTPResponse Exceptions.
- Exception Filters.
- Registering Exception filters.
- HTTPErrors.
7- What is the difference between MVC and Web API?
Ans-
MVC:
- MVC is used to create Web Apps where we can create web pages.
- For JSON it will return JSONResult from the action method.
- All requests are mapped to respective action methods.
Web API:
- Web API is used to create HTTP Services using HTTP Verbs.
- This returns JSON and XML data to the client.
- All requests are mapped to actions using HTTP verbs.
8- How can we restrict access to a methods with specific HTTP verb in Web API?
Ans- Attribute programming is used for this. Web API will support to restrict access of calling the method with specific HTTP verbs. We can define HTTP verb as attribute over the method as shown below:
[HttpPost] public void PostEmployee(Employee objEmployee) { EmployeeRepository.AddEmployee(objEmployee); }
View More:
- Interview Questions and Answers on Method and Property in .NET.
- Interview Questions And Answers on Oops-Part 1.
- Interview Questions & Answers on .NET.
- SQL Interview Questions and Answers.
Conclusion:
I hope this session about ASP.NET Web API Interview Questions is helpful for you. You can comment in comment box for any technical questions. I would like to have your feedback and suggestions.
Thank You.
best drugstore primer pharma ed pills that work quickly
indian pharmacy online online pharmacy reviews e d
dysfunction medical pharmacy best ed medication
canadian drug pharmacy online pharmacy viagra pharmacy online drugstore
discount pharmacy card dollar store drug test best drugstore face moisturizer
best drugstore face moisturizer ed meds online without doctor prescription online pharmacy viagra
Spot on with this write-up, I actually assume this web site wants much more consideration. I’ll most likely be once more to read far more, thanks for that info.
Would you be involved in exchanging hyperlinks?
Hi! I know this is kinda off topic but I was wondering if you knew where I could locate a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having problems finding one? Thanks a lot!|
What i do not realize is if truth be told how you’re not really much more smartly-preferred than you might be now. You’re so intelligent. You recognize therefore significantly in the case of this subject, made me in my view imagine it from numerous varied angles. Its like men and women are not fascinated unless it’s something to accomplish with Lady gaga! Your personal stuffs excellent. Always care for it up!|
This is the best weblog for anybody who needs to search out out about this topic. You notice a lot its virtually exhausting to argue with you (not that I actually would wantÖHaHa). You positively put a brand new spin on a subject thats been written about for years. Great stuff, simply great!
Howdy! This is kind of off topic but I need some guidance from an established blog. Is it hard to set up your own blog? I’m not very techincal but I can figure things out pretty quick. I’m thinking about making my own but I’m not sure where to begin. Do you have any ideas or suggestions? Thank you|
I used to be suggested this blog via my cousin. I am no longer positive whether this put up is written via him as nobody else recognize such designated about my problem. You are incredible! Thanks!