Watch videos with subtitles in your language, upload your videos, create your own subtitles! Click here to learn more on "how to Dotsub"

ASP.NET Web API, Part 1: Your First Web API

0 (0 Likes / 0 Dislikes)
  • Embed Video

  • Embed normal player Copy to Clipboard
  • Embed a smaller player Copy to Clipboard
  • Advanced Embedding Options
  • Embed Video With Transcription

  • Embed with transcription beside video Copy to Clipboard
  • Embed with transcription below video Copy to Clipboard
  • Embed transcript

  • Embed transcript in:
    Copy to Clipboard
  • Invite a user to Dotsub
[Microsoft ASP.net™] [www.ASP.net] [ASP.NET Web API, Part 1: Your First Web API] Hi, this is John Galloway from Microsoft with the first look at the ASP.NET Web API. ASP.NET Web API is a framework for building HTTP services on top of the .NET framework, and it ships along with ASP.NET MVC 4. [WHY USE ASP.NET Web API?] Before digging into writing some code, let's talk about why you'd want to use ASP.NET Web API. The first reason is it enables you to reach more clients. By creating HTTP services using client appropriate formats, you're making your application more broadly available. Your services can be consumed not just by browsers but also client applications, native mobile applications, tablets, and other devices. You're also allowing for interoperability with other applications which can directly consume your services. ASP.NET Web API services use content negotiation, which makes it easy to provide the right format for each client, giving XML, JSON, form-urlencoded, or custom formats to each client as appropriate. Secondly, it helps you to scale with the cloud. by using a fully asynchronous task-based service framework that provides light-weight hosting options, including Windows Azure, web or worker role, your services can really scale. Thirdly, ASP.NET Web API really embraces HTTP as an application-level protocol. It has a new modern HTTP programming model, and it's symmetrically supported on the client. You'll notice throughout this screencast series I'll be pointing out how embracing HTTP as an application protocol really simplifies our communications with clients. Let's dig in and write some code. So to take a look at your first Web API application, we'll create a new MVC 4 web application. You'll notice Web API is one of the built-in project templates, so I'm going to hit "Okay." This creates a new MVC 4 application for us but with something new— an API controller—so this example, values controller, which implements API controller, has some simple methods for returning some sample data. Things like Get, Put, Post, Delete. And if you know HTTP well, you'll notice that those map to the standard HTTP verbs. These are implemented using the standard routing behavior that's built in to ASP.NET. You'll notice we have our standard MVC routes defined, but we also have some API routes defined. The only thing different is that we don't need to map an action for these because we've already got those HTTP verbs—Get, Put, Post, Delete, etc. We've got our standard home controller built into the application, so I can run this and I'll see the home controller's index view. Now you're not going to browse directly to your Web API's output, but you can see what it's doing using the developer tools. I'm going to hit "F12" to launch those. I'm on the Network tab, and I'll hit "Start capturing." And then I'll browse to /api/values. If I look at the body of the response, it returned that value1, value2, and that maps directly to the output of this Get. So if I want to see the output of a single value and I browse to this GET /api/values/5— I'll put that in: api/values/5— and we'll see that's going to return one single value. That completes a very simple first look at an ASP.NET Web API application. In the following videos we'll be building out some more complex samples and showing how you can make use of these HTTP services. [Microsoft ASP.net™] [www.ASP.net.]

Video Details

Duration: 3 minutes and 59 seconds
Country: United States
Language: English
License: All rights reserved
Genre: None
Views: 7
Posted by: neudesicasp on Oct 3, 2013

Note: This video contains information from a pre-release version of ASP.NET Web API. For information on what changed, see the updated sample code at http://code.msdn.microsoft.com/ASPNET-Web-API-JavaScript-d0d64dd7

Caption and Translate

    Sign In/Register for Dotsub to translate this video.