ASP.NET Web API - Screencast series with downloadable sample code - Part 1 - Jon Galloway

ASP.NET Web API - Screencast series with downloadable sample code - Part 1

There's a lot of great ASP.NET Web API content on the ASP.NET website at http://asp.net/web-api. I mentioned my screencast series in original announcement post, but we've since added the sample code so I thought it was worth pointing the series out specifically.

This is an introductory screencast series that walks through from File / New Project to some more advanced scenarios like Custom Validation and Authorization. The screencast videos are all short (3-5 minutes) and the sample code for the series is both available for download and browsable online. I did the screencasts, but the samples were written by the ASP.NET Web API team.

So - let's watch them together! Grab some popcorn and pay attention, because these are short. After each video, I'll talk about what I thought was important. I'm embedding the videos using HTML5 (MP4) with Silverlight fallback, but if something goes wrong or your browser / device / whatever doesn't support them, I'll include the link to where the videos are more professionally hosted on the ASP.NET site. Note also if you're following along with the samples that, since Part 1 just looks at the File / New Project step, the screencast part numbers are one ahead of the sample part numbers - so screencast 4 matches with sample code demo 3.

Note: I started this as one long post for all 6 parts, but as it grew over 2000 words I figured it'd be better to break it up.

Part 1: Your First Web API

[Video and code on the ASP.NET site]

This screencast starts with an overview of why you'd want to use ASP.NET Web API:

  • Reach more clients (thinking beyond the browser to mobile clients, other applications, etc.)
  • Scale (who doesn't love the cloud?!)
  • Embrace HTTP (a focus on HTTP both on client and server really simplifies and focuses service interactions)

Next, I start a new ASP.NET Web API application and show some of the basics of the ApiController. We don't write any new code in this first step, just look at the example controller that's created by File / New Project.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Web.Http;

namespace NewProject_Mvc4BetaWebApi.Controllers
{
    public class ValuesController : ApiController
    {
        // GET /api/values
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET /api/values/5
        public string Get(int id)
        {
            return "value";
        }

        // POST /api/values
        public void Post(string value)
        {
        }

        // PUT /api/values/5
        public void Put(int id, string value)
        {
        }

        // DELETE /api/values/5
        public void Delete(int id)
        {
        }
    }
}

Finally, we walk through testing the output of this API controller using browser tools. There are several ways you can test API output, including Fiddler (as described by Scott Hanselman in this post) and built-in developer tools available in all modern browsers. For simplicity I used Internet Explorer 9 F12 developer tools, but you're of course welcome to use whatever you'd like.

A few important things to note:

  • This class derives from an ApiController base class, not the standard ASP.NET MVC Controller base class. They're similar in places where API's and HTML returning controller uses are similar, and different where API and HTML use differ.
  • A good example of where those things are different is in the routing conventions. In an HTTP controller, there's no need for an "action" to be specified, since the HTTP verbs are the actions. We don't need to do anything to map verbs to actions; when a request comes in to /api/values/5 with the DELETE HTTP verb, it'll automatically be handled by the Delete method in an ApiController.

The comments above the API methods show sample URL's and HTTP verbs, so we can test out the first two GET methods by browsing to the site in IE9, hitting F12 to bring up the tools, and entering /api/values in the URL:

2012-03-12 16h02_28

That sample action returns a list of values. To get just one value back, we'd browse to /values/5:

2012-03-12 16h04_22

That's it for Part 1. In Part 2 we'll look at getting data (beyond hardcoded strings) and start building out a sample application.

Published Friday, March 16, 2012 11:46 AM by Jon Galloway
Filed under: ,

Comments

# &raquo; ASP.NET Web API &#8211; Screencast series Part 5: Custom Validation HD Software Co. Blog

Pingback from  &raquo; ASP.NET Web API &#8211; Screencast series Part 5: Custom Validation HD Software Co. Blog

# &raquo; ASP.NET Web API &#8211; Screencast series Part 3: Delete and Update HD Software Co. Blog

Pingback from  &raquo; ASP.NET Web API &#8211; Screencast series Part 3: Delete and Update HD Software Co. Blog

# &raquo; ASP.NET Web API &#8211; Screencast series Part 5: Custom Validation HD Software Co. Blog

Pingback from  &raquo; ASP.NET Web API &#8211; Screencast series Part 5: Custom Validation HD Software Co. Blog

# &raquo; ASP.NET Web API &#8211; Screencast series Part 3: Delete and Update HD Software Co. Blog

Pingback from  &raquo; ASP.NET Web API &#8211; Screencast series Part 3: Delete and Update HD Software Co. Blog

# &raquo; ASP.NET Web API &#8211; Screencast series Part 4: Paging and Querying HD Software Co. Blog

Pingback from  &raquo; ASP.NET Web API &#8211; Screencast series Part 4: Paging and Querying HD Software Co. Blog

# Windows 8 and ASP.NET Web API - Part 1 - Getting Started

Many of the key Windows 8 Metro Style application features either require or can greatly benefit from

Friday, June 01, 2012 3:31 PM by Jon Galloway

# &raquo; ASP.NET Web API &#8211; Screencast series Part 6: Authorization HD Software Co. Blog

Pingback from  &raquo; ASP.NET Web API &#8211; Screencast series Part 6: Authorization HD Software Co. Blog

# &raquo; ASP.NET Web API &#8211; Screencast series Part 2: Getting Data HD Software Co. Blog

Pingback from  &raquo; ASP.NET Web API &#8211; Screencast series Part 2: Getting Data HD Software Co. Blog

# &raquo; ASP.NET Web API &#8211; Screencast series Part 2: Getting Data HD Software Co. Blog

Pingback from  &raquo; ASP.NET Web API &#8211; Screencast series Part 2: Getting Data HD Software Co. Blog

# &raquo; ASP.NET Web API &#8211; Screencast series Part 4: Paging and Querying HD Software Co. Blog

Pingback from  &raquo; ASP.NET Web API &#8211; Screencast series Part 4: Paging and Querying HD Software Co. Blog

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

Unquestionably believe that which you said. Your favorite justification appeared to be on the web the simplest thing to be aware of. I say to you, I definitely get irked while people consider worries that they just don't know about. You managed to hit the nail upon the top and defined out the whole thing without having side effect , people could take a signal. Will likely be back to get more. Thanks

Thursday, August 23, 2012 12:33 AM by http://www.windows7shop.org/

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

yuEne2  <a href="hmskcliinrwz.com/.../a>

Tuesday, August 28, 2012 10:54 AM by stvokop

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

9nOTlI  <a href="hxxkfnpfntqa.com/.../a>

Thursday, August 30, 2012 11:51 AM by gfnzxwj

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

Saturday, September 01, 2012 12:56 AM by http://www.windows7ultimate-keys.com/

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

Someone i know you ought to find that has creates shall be purchased in customers.

Friday, November 23, 2012 8:33 AM by kqdyep@gmail.com

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

Factual a friendly relationship foresees the requirements of similar as an alternative to predicate the personal.

Saturday, November 24, 2012 6:27 AM by pfvahkgasez@gmail.com

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

Romances very last every time each and every buddy thinks fresh a small fineness on the any other.

Saturday, November 24, 2012 6:10 PM by etpdskbnkj@gmail.com

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

An brother are probably not a colleague, yet a colleague are usually each brother.

Sunday, November 25, 2012 4:58 AM by gaosfobwwc@gmail.com

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

Any buddy is almost certainly not anyone, nevertheless anyone are a fabulous buddy.

Sunday, November 25, 2012 8:58 AM by kbgznmni@gmail.com

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

If you'd like a certain accountancy for your worthy of, count number relations.

Sunday, November 25, 2012 10:56 AM by pcjdbpsjju@gmail.com

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

Fancy can be the solely sane or good enough answer to the problem attached to a person's profile.

Monday, November 26, 2012 2:15 AM by xqpkvqulmwo@gmail.com

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

Really like can be the primarily reasonable and therefore good answer to the problem associated with individuals lifestyle.

Monday, November 26, 2012 1:17 PM by yrahfdr@gmail.com

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

By WebOsPublisher

 Tool Mentor: Comparing and Merging Rational Rose Models Using Model Integrator

 Tool Mentors &gt;

 Rational Rose Tool Set &gt;

 Rational Rose Tool Mentors &gt;

 Comparing and Merging Rational Rose Models Using Model Integrator

             Tool Mentor:

Comparing and Merging Rational Rose Models Using Model Integrator

      Purpose

This tool mentor describes how to use the Model Integrator to compare and

merge models.

Related Rational Unified Process information:

 Activity: Create Baselines

 Activity: Integrate Subsystem

 Activity: Integrate System

      Overview

This tool mentor is applicable for all operating systems supported by

Rational Rose.  

Tool Steps  

To compare and merge Rational Rose models:

 Prepare the models for merging

 Load and compare the models

 Merge the models

     1. Prepare the models for merging

     Before merging models, it is a good idea to check each model with the

     Rational Rose  Tools  menu item. If errors are reported, those errors should be corrected before performing a merge with

the Model Integrator.

     2. Load and compare the models

After starting Model Integrator, select the File &gt;Contributors menu

item, and then use the Contributors dialog box to load the models.

With the models loaded, Compare mode highlights the differences between two or more models.  Conflicts are displayed as well, but in Compare mode, the Merge icons are not displayed.  You can switch back and forth between Compare mode and Merge mode, so you can begin a work session in Compare mode and then switch to Merge mode if you decide to merge the models.  In Compare mode, you cannot make any changes to the model, and the Merge menu and toolbar functions are disabled.

  For

more information on comparing models, see the  Comparing Models topic in the

Model Integrator online Help.

3. Merge the models

Merge mode incorporates all of the features of Compare mode, along with additional information to support the decisions you need to make in order to successfully merge model files.  Model Integrator supports two types of merge functionality:

 Automatic Merge &#151 Model Integrator merges all changes that do not produce conflicts.

 Selective Merge &#151 Allows the user to choose the contributor for each difference found between the models to be merged.

Automatic merge takes effect when Model Integrator first enters Merge mode.  It creates a recipient model and automatically merges all unchanged or trivially changed nodes into the recipient model for you.  If the merged model has nodes that have conflicts, Model Integrator displays an icon at the location of the conflict in the browser window.  As you make choices to resolve these conflicts, Model Integrator shows you the results of your merge.

The selective merge feature lets you change the contributor at nodes that have differences as well as conflicts.  This can be useful when you do not want to accept all of the changes that a contributor is making to your model.  It is also useful when you need to correct more complicated errors such as those discovered by the semantic checking functions.

Note: You must save the merged model, otherwise the results of the merge

will not be available later.

      For

more information on merging models, see the  Merging Models topic in the Model

Integrator online Help.

Copyright

© 1987 - 2001 Rational Software Corporation

= 3 )) ||

 ((navigator.appName == "Microsoft Internet Explorer") &&

 (parseInt(navigator.appVersion)

Rational Unified

Process  

Sunday, December 09, 2012 7:09 AM by dynaimcdrive.com

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

By WebOsPublisher

Heart On Fire ico images,Heart On Fire .ico files,Heart On Fire pictograms,Heart On Fire png icons

Heart On Fire ICO

All Icons

Heart On Fire ICO Images

You can purchase these icon images for your projects. Click on icons to purchase them.

Heart on fire      Standard Dating Icons

Other icons for your projects

Home  |  Products  |  Downloads  |  Order  |  Icons  |  Support

Copyright &copy; 2005-2012 Aha-Soft. All rights reserved.

Ready Icon Sets

Perfect Toolbar Icons

Business Toolbar Icons

Database Toolbar Icons

People Icons for Vista

Multimedia Icons for Vista

Monday, December 10, 2012 6:30 PM by iconss-pack.nnm.ru

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

effectively intercept the Palestinian rockets in the air and their fear they may run out of interceptors before the Palestinians run out of rockets

Thursday, December 20, 2012 3:32 AM by ifoxhyd@gmail.com

# re: ASP.NET Web API - Screencast series with downloadable sample code - Part 1

Hi there, I enjoy reading all of your article post.

I wanted to write a little comment to support you.

Sunday, January 06, 2013 6:51 PM by Newberry

Leave a Comment

(required) 
(required) 
(optional)
(required)