How to Migrate from WCF Web API to ASP.NET Web API

Introduction

We recently announced that WCF Web API is now ASP.NET Web API. This document provides guidance on how to migrate your existing WCF Web API code to ASP.NET Web API.

Overview

The WCF Web API abstractions map to ASP.NET Web API roughly as follows

WCF Web API ASP.NET Web API
Service Web API controller
Operation Action
Service contract Not applicable
Endpoint Not applicable
URI templates ASP.NET Routing
Message handlers Same
Formatters Same
Operation handlers Filters, model binders

Web API Controllers

Update you service types to be web API controllers by first deriving from ApiController and renaming your service type so that the type name ends with "Controller".

Routing

You can directly map URI templates to routes by defining a route that matches the URI template path and then specifying the method name as the default value for the action route variable. The approach will result in one route per action, which depending on the number of actions may result in significant performance overhead.

To consolidate the number of routes consider refactoring your service so that there is one web API controller per resource.

 

 

Last edited Feb 17, 2012 at 9:27 PM by danroth27, version 5

Comments

Xyaran Sep 10, 2012 at 10:40 PM 
Anything new?

AlecDobbie Aug 16, 2012 at 8:12 AM 
Any further movement on fleshing this out?

Snaeng Apr 5, 2012 at 2:40 PM 
So.. will this be extended properly, or is this all (nothing)?