.NET Zone is brought to you in partnership with:

G. Andrew Duthie, aka devhammer, is a Technical Evangelist for Microsoft's Mid-Atlantic States district, where he provides support and education for developers working with the Microsoft development platform. In addition to his work with Microsoft, Andrew is the author of several books on ASP.NET and web development, and has spoken at numerous industry conferences from VSLive! and ASP.NET Connections, to Microsoft's Professional Developer Conference (PDC) and Tech-Ed. G. Andrew is a DZone MVB and is not an employee of DZone and has posted 41 posts at DZone. You can read more from them at their website. View Full User Profile

Building Back-end Data and Services for Windows 8 Apps: ASP.NET Web API

12.12.2012
| 3854 views |
  • submit to reddit

In this series, I'm exploring a variety of ways to build back-end data storage and services for Windows 8 apps (many of which, BTW, can also be used for other mobile and web apps as well). Here are the posts so far:

Overview

In this post, I'm going to show you how I can implement the same leaderboard service using a relatively new member of the ASP.NET stack, Web API. Web API is designed specifically for building services that are accessed via HTTP, and is a lightweight, yet highly customizable way of building RESTful services, and even supports OData as well. I'll also show you how easy it is to host services built using ASP.NET Web API using the new Windows Azure Web Sites feature.

For the sake of simplicity, I'm going to leverage the same database schema that I created in part 1 of the WCF Data Services-based solution, and will also leverage Entity Framework for modeling the data. If you have not already, you should read through the sections entitled "Creating the Database" and "Creating the Schema" in that post, before moving on. I'll wait.

Preparing a Home for our Web API

Since the last project showed how I was able to host a WCF Data Services-based OData service using a Windows Azure cloud service, this time I'm going to do things a little differently and host my Web API using Windows Azure Web Sites, a new offering (still in preview as of the time of this writing). As with cloud services, you will need a Windows Azure account to follow along. If you don't have one, you can get a 90-day free trial account.

Creating a Web Site in Windows Azure is simple. I just log into the management portal, and click on the Web Sites tab. Since I don't have any web sites yet, this is what I'll see:

AzureWebSites

Next, I'll click the link to create a web site, which prompts me with some options for how I'd like to create my web site:

AzureWebSiteOptions

Note the reminder that the service is (as of this writing) in preview, and the options for quick create, creating with a database, and creating from the gallery (a great option for when you want to stand up a site based on one of the many web apps available from the Windows Web App Gallery, such as DotNetNuke, Umbraco CMS, Orchard CMS, or WordPress). I'm going to choose Create with Database. This prompts me with the following dialog, which I've filled out with my desired web site URL (note that I'm using the free version of the service, which uses the naming pattern [mysitename].azurewebsites.net. (NOTE: You can configure your web site to use a custom domain name, but this requires switching the site to Shared or Reserved mode, which may have cost implications) Additionally, I'm specifying that I want to create the site in the East US region, and create a new database. I've left the connection string name as the default:

CreateWebSite_1

When I click the arrow for "next," I see page 2 of the Create Web Site wizard, where I provide the database settings for the new database (I'm using the same database server as for my previous project, so my login information remains the same):

CreateWebSite_2

Next, I'll click the checkmark, and let Windows Azure spin up my new website. It takes just a few minutes, and then I'm all set.

Creating a Web API Project

I'll start off similarly to the WCF Data Services project, using Visual Studio 2012, but this time, I'll start with an ASP.NET MVC4 Web Application using Visual C#. I'm calling the project GameLeaderWebAPI (note that I've specified .NET Framework 4.5 as the version for my project):

NewProjectWebAPI

Once I click OK, I'm greeted with a dialog that prompts me to select the specific ASP.NET MVC 4 template I want to work with. If I wanted to create a full MVC site with a Web API service, I'd select the Web API template, but for my current purposes, that template has a number of things I don't need (like views, for example), so I'm going to start with the Empty template, as shown below:

NewProjectWebAPI_2

Since I'm not planning on having any views, it doesn't really matter which view engine I choose, so I've left the default. When I click OK, Visual Studio creates the project for me, with folders appropriate for MVC, along with all the necessary configuration for my Web API, but without all of the default controllers and views I'd get with the Web API template. Here's what the project looks like in Solution Explorer at this point:

EmptyProjectSolutionExplorer

Before I start adding any models or API controllers, I want to make sure I'm ready to support OData in my Web API, which is currently accomplished through a nuget package. To get the package, I'll open up the Nuget Library Package Manager using Tools > Library Package Manager > Manager Nuget Packages for Solution… (note that at the time of this writing, the Web API OData package is in alpha release, so you'll need to choose "Include Prerelease" in the leftmost drop-down, as shown below, to see the package) and search for "Web API OData". Once I find the package, I simply click the Install button and click through the prompts to finish the install:

NugetWebAPIOData

Now, it's important to note that you don't need to do this to create a RESTful service with Web API. But since my previous example leveraged OData for its rich URL query functionality, I'd like to maintain that in my Web API version.

Adding the Model

Now that the project is set up, I want to add a model, and connect it to my back-end database. As noted earlier, I'm planning to use the same schema as in the previous post on WCF Data Services, so before adding the model, I created a table named GameScores in the database I created earlier, and added columns for Id, Game, Player, Score, Wins, Losses, and Ties. Note that in my WCF Data Services version, I had named the table Scores, which didn't play nicely with Entity Framework, due to the fact that the table had a column name that was the singular version of the table name, which caused EF to rename the column to Score1, which was a little confusing when querying, to say the least. With the schema in place, I can simply add a new ADO.NET Entity Model to the Models folder, and point it at my database (again, see the previous post for details on this) and my model is ready to go:

GameScoresModel

I've seeded the GameScores table with some data to make the remaining tasks easier. I did so manually, but if you want to automate the process (for example if you want to use Entity Framework Migrations), Entity Framework supports seeding your tables automatically when you update them (read more about Entity Framework here).

Defining the API

Now that my model is in place, it's time to create the API, which is done by simply adding an API Controller, which is a specialized type of MVC controller specifically for Web API. It's how we create the endpoints and logic to handle all of the HTTP requests for our API. Visual Studio 2012 provides great scaffolding support for automating the process of creating an API Controller, but I need to build the project in order for the scaffolding to find my model class. Once the project is built, I'll just right-click the Controllers folder, and select Add > Controller… and specify the Model class and Data context class, as well as the name for my controller:

AddController

Note that if you see an error message indicating that no Model classes are available, you need to build the project and try adding the controller again.

When I click Add, Visual Studio scaffolds the API Controller for me, including creating the underlying data context and creating functions for the basic CRUD operations, and my service is ready to test. But if I click the start button in the toolbar to open the site in Internet Explorer, here's what I see:

404

Oops! Turns out, there's a good reason for this. Remember how I started this project using the Empty template? Well, there aren't any views associated with the project, so there's nothing for me to see at the root URL. Thankfully, the API Controller that I scaffolded helpfully includes comments with the correct path to append to get to a given API member, as you can see below for the GetGameScores function:

// GET api/Scores
public IEnumerable<GameScore> GetGameScores()
{
     return db.GameScores.AsEnumerable();
}

If I append api/Scores to the URL shown above, I'll be prompted to open or download a file named Scores.json, which contains the response from GetGameScores (which defaults to JSON format, though Web API supports content negotiation as a means of supporting additional formats).

We're not quite done with the API, however…recall that I wanted to add some basic OData support as well.

Adding OData Support

You might think, given how simple the function GetGameScores is, that we have to do a lot of tweaking to make our API support OData query syntax. In truth, the basic level of support is super-easy to add. All I have to do is modify the GetGameScores function as follows:

// GET api/Scores
[Queryable]
public IEnumerable<GameScore> GetGameScores()
{
    return db.GameScores.AsEnumerable();
}

If you blinked, you might have missed the change. All I needed to do was add the [Queryable] attribute (which is provided by the Nuget package I installed earlier), and now my API supports OData URL queries like $filter, $orderby and more. So a query like this:

http://localhost:55830/api/Scores?$orderby=Score

returns all scores ordered by score (ascending by default…just tack on a space and "desc" to get descending results…note that if you're doing this in the browser, you should use %20 for the space). And this query:

http://localhost:55830/api/Scores?$filter=Game%20eq%20'Space Cadet'

returns all scores for the game "Space Cadet".

And with that, my Web API service is good to go…on to deployment.

Publishing a Site to Windows Azure

As with the example I build on WCF Data Services, I could start integrating my service with the games running the service locally, but I'm going to go ahead and publish the site first, so that I can use the Windows Azure version of the URL for the service.

To publish, all I need to do is right-click the project in Solution Explorer, and select Publish…, which will open the following dialog:

PublishWeb_1

I'm going to import my publishing profile, which comes in the form of a .PublishSettings file, but first I need to download this from the Windows Azure management portal page for my website, by clicking the link highlighted below in the "quick glance" section of the Web Sites page for my Azure web site:

PublishProfile

Once I've saved the file to my PC, I can go back to the Publish Web wizard and import it by clicking the Import button, selecting the file, and clicking the Open button. This will import the settings for my web site. I can click Next to view additional settings, including information on my database, and click Publish to publish my website to Windows Azure.

Using the API

Once published, I can simply make HTTP requests to the URL for my website, using the following URLs and HTTP verbs:

Getting all Scores

http://[myAzureWebsiteUrl].azurewebsites.net/api/scores – HTTP GET request

where "myAzureWebsiteUrl" is the unique portion of the URL for the published site.

Note that we can also use OData queries to return a single unique score, assuming we have the game and player name we're looking for, and the game only stores one unique score per player.

Getting a Single Score

http://[myAzureWebsiteUrl].azurewebsites.net/api/scores/5 – HTTP GET request

where 5 is the ID of the score record to return.

Updating a Score

http://[myAzureWebsiteUrl].azurewebsites.net/api/scores/5 – HTTP PUT request

Note that the URL is the same as getting a single score, with the last portion being the ID of the score to update, we simply change to using a PUT request, and provide the score object in the body of the request (by default, the API accepts JSON, but you can update it to support additional formats).

Inserting a Score

http://[myAzureWebsiteUrl].azurewebsites.net/api/scores – HTTP POST request

The URL is the same as for getting all scores, but uses the POST verb instead of GET. Again, we need to pass the score object in the body of the request as JSON.

Deleting a Score

I won't make use of this API in the game clients, but here's how to delete a score entry:

http://[myAzureWebsiteUrl].azurewebsites.net/api/scores/5 – HTTP DELETE request

where 5 is the ID of the score record to delete.

Because everything in the API uses standard HTTP verbs, our API has great usability and fidelity to the way the web works.

Wiring up the Leaderboard Clients

Since I've already walked through once the process of wiring up the leaderboard service to the games, I'm going to make this a quicker version, and refer you back to part 2 of the WCF Data Services version for additional details.

To wire the games up to the Web API version of my leaderboard service, it made sense to start with the JavaScript file I created for the WCF Data Services version, and modify it as needed to work with the new service. The updates required very few changes to the code, and allowed me to maintain a completely compatible interface between the leaderboard JavaScript library and the games. As a reminder, here's what the leaderboard JavaScript library exposes to the game client(s):

WinJS.Namespace.define("Leaderboard", {
     setPlayerName: setPlayerName,
     init: init,
     addWin: incrementWins,
     addLoss: incrementLosses,
     addTie: incrementTies,
     updateScore: updateHighScore,
     getTopTenScores: getTopTenScores,
     getTopTenWins: getTopTenWinLossTie,
     leaderboardList: leaderboardList
});

By using the namespace support in WinJS, I can hide the internals of my service behind a consistent set of functions, which makes it easy for me to switch from one back-end service to another.

Here's the full listing for the new leaderboard service library, which I've called leaderboardWebAPI.js (I've highlighted the changes, and will walk through them one by one below the listing):

(function () {

     "use strict";

  

     // Leaderboard Client for ASP.NET Web API

     // by G. Andrew Duthie

     // This code is copyright © Microsoft Corporation, and licensed under the Microsoft Limited Public License (Ms-LPL). 

     // All rights reserved. 

     // Code is provided AS-IS with no warranties.

  

     var leaderboardClient, xhrOptions, leaderboardList, scores, playerName, gameName, currentPlayerScore, diag;

  

     WinJS.Namespace.define("Leaderboard", {

         setPlayerName: setPlayerName,

         init: init,

         addWin: incrementWins,

         addLoss: incrementLosses,

         addTie: incrementTies,

         updateScore: updateHighScore,

         getTopTenScores: getTopTenScores,

         getTopTenWins: getTopTenWinLossTie,

         leaderboardList: leaderboardList

     });

  

     // player and game are required for initialization

     function init(player, game) {

         return new WinJS.Promise(

             function (completed, error, progress) {

                 if (player) {

                     playerName = player;

                 }

                 else {

                     error("Player Name is required for initialization");

                 }

  

                 if (game) {

                     gameName = game;

                 }

                 else {

                     error("Game Name is required for initialization");

                 }

  

                 // replace with the URI for your custom service

                 leaderboardClient = {

                     baseUri: "http://[myAzureWebsiteName].azurewebsites.net/api/scores",

                     query: "?$filter=Game eq '" + gameName + "' and Player eq '" + playerName + "'"

                 };

  

                 // get score record for the current game/player

                 xhrOptions = {

                     url: leaderboardClient.baseUri + leaderboardClient.query,

                     headers: {

                         "Accept": "application/json;"

                     }

                 };

                 WinJS.xhr(xhrOptions).done(function (results) {

                     var gameScore;

                     scores = JSON.parse(results.responseText);

                     if (!scores[0]) {

                         // create initial leaderboard entry

                         gameScore = {

                             Game: gameName, Player: playerName, Score: 0, Wins: 0, Losses: 0, Ties: 0

                         };

                         xhrOptions = {

                             data: JSON.stringify(gameScore),

                             headers: {

                                 "Content-type": "application/json; charset=utf-8"

                             },

                             type: "post",

                             url: leaderboardClient.baseUri

                         };

                         WinJS.xhr(xhrOptions).done(function (results) {

                             completed();

                         },

                         function (e) {

                             error(e);

                         });

                     }

                     else {

                         completed();

                     }

                 },

                 function (e) {

                     error(e);

                 });

             });

     }

  

     function getCurrentPlayerScore() {

         return new WinJS.Promise(

             function (completed, error, progress) {

                 // get score record for the current game/player

                 xhrOptions = {

                     url: leaderboardClient.baseUri + leaderboardClient.query,

                     headers: {

                         "Accept": "application/json;"

                     }

                 };

                 WinJS.xhr(xhrOptions).done(function (results) {

                     scores = JSON.parse(results.responseText);

                     if (!scores[0]) {

                         // throw exception...no score found

                         error("No score record found!");

                     }

                     else {

                         currentPlayerScore = scores[0];

                         completed(currentPlayerScore);

                     }

                 },

                 function (e) {

                     error(e);

                 });

             });

     }

  

     //updates the player name of the current player for this game - requires the name as a string

     function setPlayerName(name) {

         var namePromise = getCurrentPlayerScore();

         namePromise.done(function (currentScore) {

             if (playerName != name) {

                 playerName = name;

                 currentScore.Player = playerName;

                 xhrOptions = {

                     data: JSON.stringify(currentScore),

                     headers: {

                         "Content-type": "application/json; charset=utf-8",

                     },

                     type: "put",

                     url: leaderboardClient.baseUri + "/" + currentScore.Id

                 };

                 WinJS.xhr(xhrOptions)

                     .done(function (results) {

                         leaderboardClient.query = "?$filter=Game eq '" + gameName + "' and Player eq '" + playerName + "'";

                         showMessage("Player Name Changed.");

                     },

                     function (e) {

                         showMessage("Name could not be changed on leaderboard.");

                     }

                 );

             }

         });

     }

  

     function incrementWins() {

         var scorePromise = getCurrentPlayerScore();

         scorePromise.done(function (currentScore) {

             currentScore.Wins++;

             updateScoreRecord(currentScore);

         });

     }

  

     function incrementLosses() {

         var scorePromise = getCurrentPlayerScore();

         scorePromise.done(function (currentScore) {

             currentScore.Losses++;

             updateScoreRecord(currentScore);

         });

     }

  

     function incrementTies() {

         var scorePromise = getCurrentPlayerScore();

         scorePromise.done(function (currentScore) {

             currentScore.Ties++;

             updateScoreRecord(currentScore);

         });

     }

  

     // update score - requires new score passed as number

     function updateHighScore(newScore) {

         var scorePromise = getCurrentPlayerScore();

         scorePromise.done(function (currentScore) {

             if (currentScore.Score <= newScore) {

                 currentScore.Score = newScore;

                 updateScoreRecord(currentScore);

             }

         });

     }

  

     function updateScoreRecord(newScoreRecord) {

         xhrOptions = {

             data: JSON.stringify(newScoreRecord),

             headers: {

                 "Content-type": "application/json; charset=utf-8"

             },

             type: "put",

             url: leaderboardClient.baseUri + "/" + newScoreRecord.Id

         };

         WinJS.xhr(xhrOptions).done(function (results) {

             showMessage("Leaderboard Updated.");

         },

         function (e) {

             showMessage("Leaderboard could not be updated.");

         });

     }

  

     function getTopTenScores() {

         return new WinJS.Promise(

             function (completed, error, progress) {

                 // get top ten scores for the current game

                 xhrOptions = {

                     url: leaderboardClient.baseUri + "?$filter=Game eq '" + gameName + "'&$orderby=Score desc&$top=10",

                     headers: {

                         "Accept": "application/json;"

                     }

                 };

                 WinJS.xhr(xhrOptions).done(function (results) {

                     scores = JSON.parse(results.responseText);

                     if (!scores[0]) {

                         // throw exception...no score found

                         error("No score record found!");

                     }

                     else {

                         leaderboardList = new WinJS.Binding.List(scores);

                         completed(leaderboardList);

                     }

                 },

                 function (e) {

                     showMessage(e);

                 });

             });

     }

  

     function getTopTenWinLossTie() {

         return new WinJS.Promise(

             function (completed, error, progress) {

                 // get top ten scores for the current game

                 xhrOptions = {

                     url: leaderboardClient.baseUri + "?$filter=Game eq '" + gameName + "'&$orderby=Wins desc&$top=10",

                     headers: {

                         "Accept": "application/json;"

                     }

                 };

                 WinJS.xhr(xhrOptions)

                     .done(function (results) {

                         scores = JSON.parse(results.responseText);

                         if (!scores[0]) {

                             // throw exception...no score found

                             error("No score record found!");

                         }

                         else {

                             leaderboardList = new WinJS.Binding.List(scores);

                             completed(leaderboardList);

                         }

                     },

                     function (e) {

                         showMessage(e);

                     }

                 );

             }

         );

     }

  

     function showMessage(msg) {

         diag = new Windows.UI.Popups.MessageDialog(msg);

         diag.showAsync();

     }

  

 })();

Here are the changes I made from the WCF Data Services version:

  • Line 44, in the init function (which initializes the leaderboard data for a given game), modified the baseUri property of the leaderboardClient object to reflect the updated URL for the service
  • Line 58, updated the syntax by which I test for a valid return value from the xhr call, owing to differences in how WCF Data Services and Web API return the results
  • Line 61, updated the name of the Score property of the gameScore object. In the previous version, this was Score1 due to the aforementioned conflict between my database table name and how EF deals with pluralizing/singularizing objects and their properties
  • Lines 100 and 105, in the function getCurrentPlayerScore (which returns the first score for the given player and game), updated the syntax by which I test for and assign the value returned from the xhr call, again due to differences in how Web API returns the results.
  • Lines 123, 127, 128, and 132, in function setPlayerName (only used by Space Cadet, to update the player name if required by the game), updated the way that I add the data to the xhr request, to include the entire object (the WCF Data Services version used a custom HTTP verb, MERGE, which allowed the service to update the score record with just the new playerName as the data). Also changed the HTTP verb to PUT, as required by Web API for updates, and modified the URL for the xhr request to match that of the Web API (i.e. – /api/scores/id). Also added code to update the query property of the leaderboardClient object to include the updated playerName, fixing a bug in the previous version of the library
  • Lines 171 and 172, in function updateHighScore (which gets the current score record for the player/game, and calls another function to update the leaderboard), updated the property name from Score1 to Score, again, to match updates to my EF model
  • Lines 184 and 185, in function updateScoreRecord (called by updateHighScore, and which sends the updated score to the service), changed the HTTP verb to PUT (removing the header that specified the custom MERGE verb), and modified the URL to reflect the syntax required by Web API
  • Lines 200, 207, and 212, in function getTopTenScores, updated the naming of Score1 to Score, and the syntax by which the object returned from the xhr call is tested and passed to the constructor for WinJS.Binding.List
  • Lines 235 and 240, in function getTopTenWinLossTie, same as above.

As you can see, the list of needed changes was quite short.

One other change that I needed to make was in the HTML file for the leaderboard in Space Cadet, which uses databinding to display the score on the leaderboard, like so:

<div id="myTemplate" data-win-control="WinJS.Binding.Template">

    <div>

        <div class="win-type-x-large" style="width: 400px;">

            <span>Player: </span><em><span data-win-bind="textContent: Player"></span></em>

        </div>

        <div class="win-type-large">

            <span>Score: </span><em><span data-win-bind="textContent: Score"></span></em>

        </div>

    </div>

</div>

Notice, on line 6, that the textContent property of the second span is being bound to the value "Score". In the WCF Data Services version, this was "Score1".

With the leaderboard library for Web API complete, now all I need to do is update the HTML pages for the game client and leaderboard pages to use the new version of the library, like so:

<!-- SpaceCadet references -->
<link href="/css/default.css" rel="stylesheet" />
<link href="/css/space.css" rel="stylesheet" />
<script src="/js/leaderboardWebAPI.js"></script>
<script src="/js/appBar.js"></script>
<script src="/js/default.js"></script>
<script src="/js/sound.js"></script>
<script src="/js/ship.js"></script>
<script src="/js/starField.js"></script>

Now I can run the game (in this case, Space Cadet), and here's what I'll see if I beat my previous high score:

screenshot_12052012_211304

which tells me that my service is working properly. But just to be sure, I'll check the leaderboard as well:

screenshot_12052012_211829

The data (minimal though it may be) reflects what's in the database, so it's looking good!

Wrap-up

In this post, you've seen how I created a Web Site in Windows Azure, created a new ASP.NET Web API project, used Entity Framework to create a model of the data I showed in the previous version of the leaderboard service, and created a new API Controller, leveraging Visual Studio's powerful scaffolding to automatically generate an API on top of my data model. I also showed how I could quickly download a Nuget package to add basic OData query support on top of Web API with the addition of a single metadata attribute. You've also seen how with a few simple updates, I created a new version of my leaderboard JavaScript library that works with the Web API version of the leaderboard service.

You also saw how I was able to use the new Web Sites feature of Windows Azure to quickly provide a spot in the cloud for my service, with simple Web Deploy-based publishing from Visual Studio to streamline the process of deploying my service to the cloud. While I didn't have time to cover it in detail in this post, Windows Azure Web Sites also provides robust monitoring, error logging, configuration options, etc. all from the management portal, simplifying the management of my Web Site.

Here are the advantages and disadvantages, in my view, of using ASP.NET Web API for this kind of service:

Advantages

  • Mature platform – While Web API is relatively new, SQL Server and Entity Frameworkhave each been around for numerous versions, and have had time to improve and grow over that time. Maturity also means greater familiarity for .NET developers.
  • Data format options – can return data in XML (ATOM) or JSON format, or other formats for which type formatters are configured. Content negotiation makes it pretty easy support multiple types for both input and output. See the ASP.NET Web API site for more information, videos, and tutorials. 
  • Customizable – ASP.NET Web API is a fully customizable solution, with powerful routing, content negotiation, and other features that you can leverage.
  • Query flexibility – While the implementation I showed only supports a subset of query types, OData's powerful query syntax makes it easy to work with the service through JavaScript, simply by building the appropriate URL and making the appropriate HTTP requests.

Disadvantages

  • Complexity – While arguably a little simpler and easier to understand than the WCF Data Services version of the leaderboard service, this version still has a fair number of technologies used. The scenario I've shown is deliberately simple, so as to illustrate the end-to-end solution, so expect a little more work when it comes to more complex schemas, adding robust data validation, etc. 
  • No client library for JavaScript apps – as with the WCF Data Services version, when working with this service from JavaScript, you have to construct your own library for interacting with the service (well, you could just write the code to call the APIs directly in your client code, but who'd do that?).
  • New platform – ASP.NET Web API is a newcomer to the ASP.NET stack. While it's been through a good bit of testing in preview versions, it's still new enough to unfamiliar to many devs. As I showed, it's pretty easy to implement, though. And some parts of the stack I used (such as the Nuget package that adds OData support to Web API) are preview releases, which may argue against using them in a production situation.

As with the previous discussion of a WCF Data Services-based leaderboard service, whether ASP.NET Web API is the right solution for your back-end depends on a number of factors, not limited to your familiarity with ASP.NET and related technologies, and your willingness to use relatively new platform technologies. This was my first major foray into Web API, and I was pleasantly surprised by how easy it was to get the basic service up and running. I'm looking forward to digging deeper into Web API, and in fact, it's one of the technologies that's under consideration as the basis for the next version of my Community Megaphone site.

What's Next?

In the next part of this series, I'll tackle the final approach to building back-end services that I discussed in the overview post, using Windows Azure Mobile Services to create another version of the same leaderboard service.

While you're waiting, why not sign up for Generation App? There are lots of great resources available for building Windows 8 apps (and now for Windows Phone 8 as well), including new information on a variety of app frameworks from partners that make it fast and easy to build apps and games for Windows 8. It's free, and you control how often updates are sent, so there's no good reason to pass it up. Sign up now!







Published at DZone with permission of G. Andrew Duthie, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)