
Exercise 2: Create a Read/Write Web API. This hands-on lab includes the following exercise: If you are not familiar with the Visual Studio Code Snippets, and want to learn how to use them, you can refer to the appendix from this document " Appendix A: Using Code Snippets". Microsoft Visual Studio Express 2012 for Web or superior (read Appendix B for instructions on how to install it).įor convenience, much of the code you will be managing along this lab is available as Visual Studio code snippets. The following is required to complete this hands-on lab: In this hands-on lab, you will learn how to: This site will continue to provide late-breaking information, samples, and news related to Web API, so check it frequently if you'd like to delve deeper into the art of creating custom Web APIs available to virtually any device or development framework.ĪSP.NET Web API, similar to ASP.NET MVC 4, has great flexibility in terms of separating the service layer from the controllers allowing you to use several of the available Dependency Injection frameworks fairly easy.Īll sample code and snippets are included in the Web Camps Training Kit, available at. The ASP.NET Web site has an area dedicated to the ASP.NET Web API framework at. This lab requires a basic understanding of HTTP, REST, and assumes you have a basic working knowledge of HTML, JavaScript, and jQuery. The contact manager will expose the RESTful for listing, adding and removing contacts, among others. The REST architectural style has proven to be an effective way to leverage HTTP - although it is certainly not the only valid approach to HTTP. As a result, Web API is both flexible and easy to extend.
In fact, one goal of Web API is to not abstract away the reality of HTTP. At the same time, Web API naturally exposes the HTTP programming model. Because it is built on top of the ASP.NET MVC runtime, Web API automatically handles the low-level transport details of HTTP. ASP.NET Web API is a set of components that simplify HTTP programming. It is also a powerful platform for building Web APIs, using a handful of verbs (GET, POST, and so forth) plus a few simple concepts such as URIs and headers.
In recent years, it has become clear that HTTP is not just for serving up HTML pages. You will also build a client to consume the API.
Hands on lab: Use Web API in ASP.NET 4.x to build a simple REST API for a contact manager application.